PDA

View Full Version : Email Scripts


Crumpy1
06-04-2013, 05:24 PM
I am unsure how helpful this page maybe, but have found an answer to this issue "I think"!? :/ here https://github.com/elclanrs/jq-idealforms/issues/42 (http://stackoverflow.com/questions/15782347/jq-idealforms-send-form-via-ajax)

However i do not understand what exactly in need to do so i would appreciate it if someone could tell me where to insert this code in html...

onSuccess: function() { $.post('yourfile.php', $myform.serialize()) }

also is the yourfile.php the success.php page or the php script?

Sorry for being dumb!

Thanks

edbr
06-05-2013, 05:38 AM
thas a from to login not mail isnt it?

Crumpy1
06-05-2013, 07:13 PM
Yes, sorry I did not realise.

Do you know how to mail a form using Ajax? Either with a free script or paid plugin?

Thanks

gentleone
06-05-2013, 09:20 PM
I've made a simple form on a client site which sent the data through AJAX (jQuery to be precise). Have a bit more patient and I will post some stuff here for you.

gentleone
06-05-2013, 11:17 PM
Here's a simple form which come on a contact page or such. I've used HTML5 form validation, but I will also validate within send.php. If you don't use a HTML5 doctype then you can leave out the 'placeholder' and 'required' attributes and change type=email to type=text.

With this example both files (contact page and sent.php) in the same directiry.


<form action="" method="post" id="contact-form">

<fieldset>

<label for="nane">Name</label>
<input type="text" name="name" placeholder="Your full name" required />

<label for="email">E-mail address</label>
<input type="email" name="email" placeholder="name@example.com" title="use a valid e-mail address" required />

<label for="dummy" class="dummy">Telephone</label>
<input type="text" name="dummy" class="dummy" />

<label for="textarea">Message</label>
<textarea name="textarea" required></textarea>

</fieldset>

<input type="submit" id="submit" value="submit" />

<div id="response"></div>

</form>


On this page you add also the following scripts. Preferably before the closing body tag:


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script>
$('#submit').click(function(){

$.post("sent.php", $("#contact-form").serialize(), function(response) {

$('#response').html(response);
$('#response').fadeIn().delay(3000).fadeOut();
$('input, textarea').val(''); // clear the fields after submitting the form

});
return false;

});
</script>


In your CSS you style the form the way you want, but most important is that you add this to it as well:


.dummy { display: none }


You see a telephone label and input field with a class 'dummy'. This input field is for the spam bots. I hide it for real users, so they won't fill this in, but bots will, because they're not that smart to check the CSS. Well... most of them.
In sent.php I do a check to see if that field gets filled in and if so it won't sent the form.

Here's a sent.php:

I only validate the e-mail address in this example, but you might want to validate the textarea as well.

<?php

$name = $_POST['name'];
$email = $_POST['email'];
$dummy = $_POST['dummy'];
$textarea = $_POST['textarea'];

$to = 'you@email.com';
$subject = 'Message from your website';
$message = .$textarea;
$headers = 'From: '.$email . "\r\n";

if($dummy)
echo '<p class="error">You\'re a dumb bot</p>';
else {
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
mail($to, $subject, $message, $headers);
echo '<p class="succes">Thank you for your message!</p>';
else {
echo '<p class="error">Invalid e-mail address. Please provide a correct email address!</p>';
}
}

?>

edbr
06-06-2013, 02:14 AM
i like that dummy fiel idea. is it very effective? might be an effective alternate to captcha or additional belt and braces plan.

gentleone
06-06-2013, 10:22 AM
i like that dummy fiel idea. is it very effective? might be an effective alternate to captcha or additional belt and braces plan.
Yes, the honeypot technique is very effective and a much better alternative than any captcha. I use it on several sites for years and they don't receive spam through their contact form. The technique is quite old and therefore pretty known by now, so I guess it's waiting for the moment the bots gets smarter and will check the CSS and ignore the dummy field :)

edbr
06-07-2013, 02:11 AM
well i missed that, yes annoying but gifted are some of these spammers. i will definitely use it as additional to captcha though, at least. i sent a pm to Domedia as it might be interesting to see if it may help stem spam sign ups as the bot that hit us is spedifically a captcha beater ASIK. good info thanks :)

gentleone
06-07-2013, 10:58 AM
It's even better and more save to give it a better name then 'dummy' and also not to give it a class name 'dummy'. Bots can check these attributes and if it's reads as an unusual name for them, they might skip the field too.
If you don't need a telephone number from your visitors, then it's better to give it 'for="telephone" and name="telephone"'.

But now the browsers' autocomplete form function will lkely fill this field in without knowing by the visitor, so he/she might get the message 'You're a dumb bot" :shock: To solve this you will have to add the following attribute to that field: autocomplete="off".

To target the field in your CSS without a class name or ID, you can use one of the new CSS3 selectors such as :nth-child() or :nth-of-type(), but these are not supported in IE8 and below, so you need selectivizr.js (http://selectivizr.com/) for them.

gentleone
06-07-2013, 11:01 AM
Oh... if you keep that field as the first field in the form and you don't need to support IE6 :), you can just use :first-child to target that field in your CSS. No need for CSS3 selectors.

Crumpy1
06-08-2013, 12:13 PM
Hi Gentleone,

Thank you so much for the scripts, however i do not really understand how to intergrate the code into my form.

I will create a dummy field as you mensioned as i agree that this is an amazing idea instead of capthca with autocomplete=off.

Here is the current page i am looking to add your scripts to http://thebarkercompany.co.uk/TYS/contact.php, could you please just let me know how to modify your sent.php to match my form and where to insert your scripts? do i change $name to the field name i.e Name=Telephone e.g field with Name=Telephone to $Telephone?

Hope this makes sense.

Thank you again for the scripts and support!

gentleone
06-11-2013, 09:23 PM
Hi Crumpy1,
Apologies for the delay! Due to some heavy workload I'll do this quick, but you will have to figure out the rest for yourself or someone else might have the time to help you.

1. Keep the form action attribute empty

<form action="" method="POST" class="ideal-form" id="contact" accept-charset="iso-8859-1">

2. add a div after your 'telephone' field div and which gonna hold the bot field with the name 'age' or something. Don't add any attributes for your idealforms script.

<div>
<label for="age">Age</label>
<input type="text" name="age" autocomplete="off" />
</div>

3. To hide that label and input filed with CSS we're going to target the div that holds them, but we don't give that div an ID or class name either. We simply use the DOM tree. That div is the 5th child within the parent <form> with id 'contact', so we do this.

#contact > div + div + div + div + div { display: none }

Usually it's not a good idea to target your elements like this, cause it takes more time for the browser to find that div, than if you would use a class name. But we don't want the bot to be suspicious, so therefore like this.

4. give the submit button an ID 'submit'

5. add an empty div tag with the id 'response' before your closing </form> tag

6. The jQuery function to sent the form would be now something like this

<script>
$('#submit').click(function(){

$.post("sent.php", $("#contact").serialize(), function(response) {
$('#response').html(response);
$('#response').fadeIn().delay(3000).fadeOut();
$('input[type="text"], input[type="email"], textarea').val('');

});
return false;

});
</script>

7. You use idealform.js for your form validation, but it's perhaps wise to do also some PHP validation in sent.php. On the other hand if someone disables javascript in the browser to bypass the form validation, the form data can't be sent anyways, because we use javascript - jQyery .post() - to submit/sent the form data. SO.... here's sent.php, but Edbr can better check this for you, cause my PHP is quite rubbish :)

<?php

$type = $_POST['type'];
$name = $_POST['Name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$age = $_POST['age'];
$comments = $_POST['comments'];

$to = 'your@email.com';
$subject = $type;
$message = $name,$phone,$comments;
$headers = 'From: '.$email . "\r\n";

if($age)
echo '<p class="error">You\'re a bot</p>';
else {
mail($to, $subject, $message, $headers);
echo '<p class="succes">Thank you for your message!</p>';
}

?>

Also I see the idealforms.js validation erros/alerts uses the browser alert, so you might want to try to figure out that these messages also get's parsed in #respond.

Crumpy1
06-12-2013, 10:31 AM
Thanks Gentleone for the info

I have added the code where appropiate but encountered a few errors. Firstly the div + div + div section removed my comments and buttons aswell as the hidden field. I have moved the new div "Age" the last but 1 div in the code and added 2 + divs to the css to make these show up so now response and age are hidden.

After adding all the code i am no longer getting any in browser validation messages for the form and my submit button does nothing is this to do with my idealforms not being parsed with respond?

Also I see the idealforms.js validation erros/alerts uses the browser alert, so you might want to try to figure out that these messages also get's parsed in #respond.

I have reuploaded the amended page to the same location http://thebarkercompany.co.uk/TYS/contact.php

I appreciate any help any1 can offer.

Thanks Again!

gentleone
06-12-2013, 01:14 PM
I have moved the new div "Age" the last but 1 div in the code and added 2 + divs to the css to make these show up so now response and age are hidden.
Sorry, my bad! Put it back after 'telephone' div and use this instead in your CSS. We have to make sure we count only the fifth div from the first div, so like this:

#contact > div:first-child + div + div + div + div { display: none }


After adding all the code i am no longer getting any in browser validation messages for the form and my submit button does nothing is this to do with my idealforms not being parsed with respond?
See what it does now. You might have hidden the #response div before, so therefore you didn't see any 'succes' message on the page.

Crumpy1
06-12-2013, 01:43 PM
Sorry, my bad! Put it back after 'telephone' div and use this instead in your CSS. We have to make sure we count only the fifth div from the first div, so like this:

#contact > div:first-child + div + div + div + div { display: none }



See what it does now. You might have hidden the #response div before, so therefore you didn't see any 'succes' message on the page.

Thank you for the fast reply, i have made all the corrections you stated above, but their is no diffrence when clicking submit, the validation or success messages no longer load.

Any ideas?

gentleone
06-12-2013, 03:59 PM
I still see the old CSS rule. Not the one I just posted here.

Crumpy1
06-12-2013, 04:41 PM
I still see the old CSS rule. Not the one I just posted here.

Sorry I did not relize that that had not overwritten properly.

I have reuploaded with new css rule, however the error still persits. I get the inform validation however the error messages it produces i.e 5 incorrect fields etc do not show, neither does your thank you message.

Have you ever had this issue? Any ideas?

Thanks for the help, i appreciate you are busy!

Crumpy1
07-08-2013, 08:57 AM
Here's a simple form which come on a contact page or such. I've used HTML5 form validation, but I will also validate within send.php. If you don't use a HTML5 doctype then you can leave out the 'placeholder' and 'required' attributes and change type=email to type=text.

With this example both files (contact page and sent.php) in the same directiry.


<form action="" method="post" id="contact-form">

<fieldset>

<label for="nane">Name</label>
<input type="text" name="name" placeholder="Your full name" required />

<label for="email">E-mail address</label>
<input type="email" name="email" placeholder="name@example.com" title="use a valid e-mail address" required />

<label for="dummy" class="dummy">Telephone</label>
<input type="text" name="dummy" class="dummy" />

<label for="textarea">Message</label>
<textarea name="textarea" required></textarea>

</fieldset>

<input type="submit" id="submit" value="submit" />

<div id="response"></div>

</form>
On this page you add also the following scripts. Preferably before the closing body tag:


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script>
$('#submit').click(function(){

$.post("sent.php", $("#contact-form").serialize(), function(response) {

$('#response').html(response);
$('#response').fadeIn().delay(3000).fadeOut();
$('input, textarea').val(''); // clear the fields after submitting the form

});
return false;

});
</script>
In your CSS you style the form the way you want, but most important is that you add this to it as well:


.dummy { display: none }
You see a telephone label and input field with a class 'dummy'. This input field is for the spam bots. I hide it for real users, so they won't fill this in, but bots will, because they're not that smart to check the CSS. Well... most of them.
In sent.php I do a check to see if that field gets filled in and if so it won't sent the form.

Here's a sent.php:

I only validate the e-mail address in this example, but you might want to validate the textarea as well.

<?php

$name = $_POST['name'];
$email = $_POST['email'];
$dummy = $_POST['dummy'];
$textarea = $_POST['textarea'];

$to = 'you@email.com';
$subject = 'Message from your website';
$message = .$textarea;
$headers = 'From: '.$email . "\r\n";

if($dummy)
echo '<p class="error">You\'re a dumb bot</p>';
else {
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
mail($to, $subject, $message, $headers);
echo '<p class="succes">Thank you for your message!</p>';
else {
echo '<p class="error">Invalid e-mail address. Please provide a correct email address!</p>';
}
}

?>


I have got my web forms working now and managed to integrate Ajax to send the content.

I am now looking to add this dummy field idea of yours to this but unsure how / where to add this?

Do i add this to my php script file or can i do this within the webpage? Also what would the php code be to just basically say if "Age" is completed say "You're a dumb bot" or if its not do nothing and load the script as normal.

The form i am trying to add this to is here http://transformyourshape.co.uk/contact.php

I can also upload a copy of my script should you require this.

Thanks

gentleone
07-08-2013, 12:07 PM
Yes you add this to I assume 'ContactUsForm.php' and i wrote it all down for you before. Just make an '$age' variable and make an if/else statement before sending the form.

I'm not a PHP guru, but I this should be fairly easy, cause the bot check variable '$age' will be the 'if' statement and all the other variables with the mail() part will go in the 'else' statement.

Post the code of ContactUsForm.php here in the thread, so we can have a look where this should be added.

edbr
07-09-2013, 02:38 AM
if (!empty($age)) {
echo "die scum bot";
}
else{
// do stuff
}

should be enough to trap it

Crumpy1
07-09-2013, 10:31 AM
Yes you add this to I assume 'ContactUsForm.php' and i wrote it all down for you before. Just make an '$age' variable and make an if/else statement before sending the form.

I'm not a PHP guru, but I this should be fairly easy, cause the bot check variable '$age' will be the 'if' statement and all the other variables with the mail() part will go in the 'else' statement.

Post the code of ContactUsForm.php here in the thread, so we can have a look where this should be added.

Hi Gentleone,

Here is a copy of a demo version of my script https://dl.dropboxusercontent.com/u/104598901/ContactUsForm.php If you could tell me which line to add the code this would be much appreciated.

Thank you edbr for the code i need to insert, again if you could tell me where it goes and i will add this to it.

Just a quick question, can i just do a simple #botfield {display:none;} to the css or are bots prone to detecting these?? I know you guys gave me an example of div + div + div etc but i don't understand how this works when you need to remove divs in the middle of a form.

Thanks Gentleone & Edbr!!

gentleone
07-09-2013, 11:59 AM
if (!empty($age)) {
echo "die scum bot";
}
else{
// do stuff
}

should be enough to trap it
Aren't you saying here if the age field is empty 'die' and if not empty do somthing else? The bot should be filling this in order to recognize it's a bot, so...

Should be just something like this:

if($age) {
die();
}
else{
// do stuff like
mail();
}

gentleone
07-09-2013, 12:11 PM
Hi Gentleone,

Here is a copy of a demo version of my script https://dl.dropboxusercontent.com/u/104598901/ContactUsForm.php If you could tell me which line to add the code this would be much appreciated.
So :shock:
That's a bloody long mailer script... loads of validation, UA sniffing and stuff, but seriously you don't need all this for the form you have on your page.
I don't know where to put it... Edbr might know :mrgreen:

Just a quick question, can i just do a simple #botfield {display:none;} to the css or are bots prone to detecting these?? I know you guys gave me an example of div + div + div etc but i don't understand how this works when you need to remove divs in the middle of a form.
You can do that, but I don't know how smart the bots are these days and if they can/will check ID's in the CSS.
It might be a bit paranoid to target a div like this through the DOM tree and you will have to change the CSS as well if you add/remove a div/input which won't be handy with a CMS behind it, but it's up to you.

edbr
07-10-2013, 05:00 AM
you could just use if (!empty($age)) {
echo "die scum bot";
exit
}
if the condition is met ( not empty) the script will stop anyway

Crumpy1
07-11-2013, 07:08 PM
you could just use if (!empty($age)) {
echo "die scum bot";
exit
}
if the condition is met ( not empty) the script will stop anyway

Thank Guys, Firstly i know my script is mega long, but i know 0 php :sad: so i purchased a premade script and simply fill in about 5 boxes to get my scripts working.

I know that my display:none rule is not perfect but i do not understand you div + div rule when their is a div midway that needs to be removed, i can only get this to work if i add it to the very last div of the form, which i pressume will still work???? :|

Thanks edbr for the simplfied if statement, if this will be all i need then great. Could you please tell me where in my script to add this??

Cheers

Crumpy1
08-19-2013, 09:58 AM
you could just use if (!empty($age)) {
echo "die scum bot";
exit
}
if the condition is met ( not empty) the script will stop anyway

Hi Edbr,

I am still trying to get this working, i have been busy with stuff over the last month so just getting back around to this as i am being bomarded with spam!

Am i correct in assuming that your above code says...

If field with id of "age" is NOT emtpy then say "die scum bot" if it is empty carry on as normal?

From a glance it looks like it says if !empty (which is what i want) say youre a bot?

If this is corrects that fine, just wanted to double check before i started integrating this on my forms. If it's not correct how would i write if $age is empty carry on, if not do nothing?

Cheers Edb

edbr
08-19-2013, 10:12 AM
i got a bit dizzy reading that :)

if (!empty($age)) { //if not empty
echo "die scum bot"; // gives a message if not empty
exit // script stops
}

that clearer?

Crumpy1
08-19-2013, 10:15 AM
i got a bit dizzy reading that :)

if (!empty($age)) { //if not empty
echo "die scum bot"; // gives a message if not empty
exit // script stops
}

that clearer?

Yes thats alot clearer :D

I understand now what it mean and what each line does!

Just out of interest, if i wanted to write this the other way around so if it is empty how would i write that?

edbr
08-19-2013, 10:27 AM
if (empty($age)) {
echo "field is empty"; }

Crumpy1
08-19-2013, 10:30 AM
Got it!

Thanks for the assistance!

Crumpy1
08-19-2013, 07:36 PM
Hi Edbr,

Can you help me locate where to add the code in my script?

https://dl.dropboxusercontent.com/u/104598901/Script.php

Thanks Edbr, i appreciate your help!

edbr
08-20-2013, 02:11 AM
if you add it at line 5 for example, it will die if not empty or continue if it is

Crumpy1
08-20-2013, 10:03 AM
The developer has emailed me the following message, but will not help me further without paying a custom development charge...

"that code should be placed immediately after the opening <?php tag (line #2 of the file), however the code that you provided seems to have errors (missing semicolon after exit, required register_globals enabled), I'm not sure if it will work properly."

How do i enable registered globals?

I sent this code in the email....

if (!empty($age)) { //if not empty
echo "die scum bot"; // gives a message if not empty
exit // script stops
}

Cheers

edbr
08-20-2013, 12:16 PM
Yes typo i missed the semi colon put it in

gentleone
08-20-2013, 12:25 PM
How do i enable registered globals?
You could/should use .htaccess for this. If you have already one on the server just add the lines to it, if not create a .htaccess file.
http://www.vitez-studios.com/development/tutorials/how-to-enable-or-disable-register-globals-via-.htaccess.html





...

Crumpy1
08-20-2013, 03:00 PM
Yes typo i missed the semi colon put it in

Thanks edbr, i added it, just need to sort the register_gloabl issue!

You could/should use .htaccess for this. If you have already one on the server just add the lines to it, if not create a .htaccess file.
http://www.vitez-studios.com/development/tutorials/how-to-enable-or-disable-register-globals-via-.htaccess.html
...

I do not have a .htaccess fiile so i will need to create one. Is there anywhere that i can download one from and just make the changes as mentioned above?

gentleone
08-20-2013, 03:08 PM
I think you better can contact your web host about this, because I see register_globals has been deprecated since PHP 5.3.0., and removed in PHP 5.4.0. so I'm not sure which PHP version you have on your web server.

edbr
08-21-2013, 02:02 AM
not sure im following these comments . here is a simple testy for you. upload it and try it, if you fill in Spam the script will exit, if you don't it will print the array, ie didnt stop the script. in reality then Spam would be a hidden field

<?php
$age= $_POST['age'];
if (!empty($age)) {
echo "die scum bot";
}
else{
print_r($_POST);
}
?><!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>

<body>
<form name="form1" method="post" action="">
<p>
<label for="email">Email</label>
<input type="text" name="email" id="email">
</p>
<p>
<label for="name">Name</label>
<input type="text" name="name" id="name">
</p>
<p>
<label for="age">Spam</label>
<input type="text" name="age" id="age">
</p>
<p>
<input type="submit" name="send" id="send" value="Submit">
</p>
</form>
</body>
</html>

edbr
08-21-2013, 02:05 AM
if I find some spare time rattling about i will write an email sending script using this principle

edbr
08-21-2013, 03:02 AM
here's a test mail form and sender, do not leave this as it can be used by all as it is requires you to put an email address in , you can of course code it using the alternate hard code i show commented, but you can test your ability to send emails

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style>
label{ width:200px; float:left}
input{ width:400px; float:left}
</style>
</head>

<body>
<form name="form1" method="post" action="">
<p>
<label for="email">Email</label>
<input type="text" name="email" id="email">
</p>
<p>
<label for="name">Name</label>
<input type="text" name="name" id="name">
</p>
<p>
<label for="subject">Subject</label>
<input type="text" name="subject" id="subject">
</p>
<p>
<label for="age">Spam</label>
<input type="text" name="age" id="age">
</p>
<p>
<label for="message">Message</label>
<textarea name="message" id="message" cols="45" rows="5"></textarea>
</p>
<p>
<input type="submit" name="send" id="send" value="Submit">
</p>
</form>

<?php

/*
Edit your field names from your form

*/

$spam= $_POST['spam'];
$email= $_POST['email'];
//$email= "Me@mydomain.com"; ALTERNATE

$subject= $_POST['subject'];
$message=$_POST['message'];

$rows []= array(
$email
);

if(empty( $email)){ // or if(count($rows) === 0)
echo 'Please fill in your email address'; echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";
}

if (!empty($spam)) {
echo "die scum bot";
}

if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
elseif ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) ) {

echo "<h4>Characters not allowed in this field</h4>";
echo "<a href='javascript:history.back(1);'>Back to e mail form</a>";

}
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=utf-8" . "\r\n";
$headers .= 'From: <webmaster@example.com>' . "\r\n";

if (mail($email,$subject,$message, $headers)) {
echo "<h4>Thank you for sending email</h4>";
}

?>

</body>
</html>

Crumpy1
08-21-2013, 09:29 AM
Thanks guys for the help with this, i have got this working using my existing scripts but mix and matching the ideas and code you provided.

I add to my existing scripts...

$Age= $_POST['Age'];
if (!empty($Age)) {
echo "You're a web-bot";
exit;
}

I have tested this live on my server and it does work correctly, just need to set display:none and done!

Thanks with all the time you guys put in the help me with this, i appreciate it got a bit confusing and lengthy at some parts!

edbr
08-22-2013, 01:53 AM
good to hear thank you and welcome. Actually i continued witgh e
the mail form and was thinking too ask you to test it re the config to se if its confusing or not. You up for it?

Crumpy1
08-22-2013, 10:22 AM
good to hear thank you and welcome. Actually i continued witgh e
the mail form and was thinking too ask you to test it re the config to se if its confusing or not. You up for it?

Yes, no problem! its the least i can do after the help you have given!

edbr
08-23-2013, 02:37 AM
hanks, ill post the stuff later today. Im pretty bad at explaining things as im sure is obvious :) so i would like to see if it is understandable from the view of some one like your sel or even some one making a first dabble into php and mail handling so I would welcome any feed back from you and any one else whao wants to give it a go. Im thinking simple version, simple with javascript validation added . and then maybe with jquery, depending on my goldfish like span of attention :)

edbr
08-23-2013, 05:59 AM
ok Mark 1. you can download a zip file from here. http://www.concord-bali-villas.com/downloads/

Crumpy1
08-25-2013, 12:17 AM
ok Mark 1. you can download a zip file from here. http://www.concord-bali-villas.com/downloads/

Hi Edbr,

I have looked at the files you uploaded, in form.php the submit button is missing and all text fields are labels only, no text box so have been unable to actually test the form.

I have looked at the script and it seems ok and self explanatory. My only suggestion would be to add a few more variables for a specific field to show how to add more than 1 validation rule. If i was using your script to for e.g. have comments required with min of 50 characters and max 500 characters i would not really know where to put these extra rules or what the code would be for that type of validation. Also you could possibly as comments to each rule to say what they actually do, i only managed to figure some stuff out by looking at the actual error message and not the code

I understand that this is only for beginners like me, but sometimes seeing more than 1 option makes it easier to see how things are structured. Also i think it may be better to have 1 field as optional. I maybe wrong but it looks like all of the fields must be not be empty, so it maybe better to define each ID in the code to assign rules to.

These are just my opinions, if i have looked to deep into some of the suggestions (as i sometimes do :cry:) then amend or don't as you see fit.

Hope this helps somewhat

edbr
08-25-2013, 01:56 AM
Hm i might have packed the wrong file i will check tomorrow when i am back at my desktop.

all good points and will look at them, i was thinking to add more as this goes along so welcome the comments.
I Once changed a wheel on my car forgetting to tighten the wheel nuts culminating in the experience of seeing my front tyre overtaking me on the M11, so i am always open to checking :)

edbr
08-25-2013, 01:59 AM
I just downloaded it and i have indeed packed the wrong file. I actually added instruction on the file page so i will wait till tomorrow as i don't want to do it again today,

edbr
08-26-2013, 07:56 AM
ok i re packed it , please try now.
I was thinking about your comments but rather than complicate a very simple form which , i think might suit many new sites, i will add a new one. I did it yesterday so will check but it has the following
1 javascript validation made simpler using a framework and jquery. It sounds over the top but in reality means not adding and javascript code at all. I thought it was useful
The mail sending is done using a class, and while OOP can be a bit scary , it also is very easily used.
both of these are done using open source scripts i think it will be a good item for the tool box.
I hope for your comments on this too, ill also add a demo i think so give me a while to naff about, as i will add a test as well as a mailing script

edbr
08-26-2013, 08:23 AM
in fact would this be of interest do you think? still simple but validated both client and serverside for empty,lengt,h url and e mail plus all posts sanitized
http://www.concord-bali-villas.com/demo/

edbr
08-26-2013, 10:02 AM
just have an issue matching the js and php validation for url's to sort

Crumpy1
08-26-2013, 01:29 PM
in fact would this be of interest do you think? still simple but validated both client and serverside for empty,lengt,h url and e mail plus all posts sanitized
http://www.concord-bali-villas.com/demo/

Yes this would probably be better than the original concept, as it helps users complete the fields as they go, rather than keep going back and correcting errors.

Dunno how difficult this would be to script for the validation side of things though, but definitely better!

edbr
08-27-2013, 02:56 AM
ok i will get an explanation /read me page up. I thought the process was the easiest ive seen which is why i used it. had an issue though a the serverside url validation insists on a real address while the javascript doesnt but not sure thats a huge problem

second issue was i was told the form could not be filled using Ipad which is odd. i checked on iPhone and it was ok, so i would appreciate any one with an apple-aid tablet to check for me

Crumpy1
09-01-2013, 01:13 PM
ok i will get an explanation /read me page up. I thought the process was the easiest ive seen which is why i used it. had an issue though a the serverside url validation insists on a real address while the javascript doesnt but not sure thats a huge problem

second issue was i was told the form could not be filled using Ipad which is odd. i checked on iPhone and it was ok, so i would appreciate any one with an apple-aid tablet to check for me

I have tested this on both my iPad and iPhone and it works perfectly fine on both for me.

I will keep on eye out for the read me file!

edbr
09-02-2013, 02:06 AM
good to hear , nearly done just had a new business proposal to write and got distracted