Js form

Ok so I got a javascript contact form here:

http://www.orangestonephotography.com/under/

But when you click submit it doesn’t do anything, the symbol keeps rotating. Can anyone please help me?

The ajax request ends up in a 404. Your ajax-actions.php script must be in the wrong place.

You should install Firebug. It took about 10 seconds to find the source of the problem using it.

oh crap i dont even have ajax-actions.php :X

is there a tutorial on how to make something like that?

i ahve firebug no idea how to use it.

Looks like you don’t understand how your form works. Are you aware that to process what the person inputs into the form you need a script living on the server? A program that will decide what to do with the inputted information?

i understand that i just thought the php file was on there but its not. i guess i have to redo the contact form entirely then.

Not really, all you have to do is write the script for ajax-actions.php! Is this a packaged CMS or something of the sort?

The form and the server-side logic are pretty much completely separate things. You don’t need to re-do the contact form.

i have no idea how to write it though :X

no this was made from a colleague who i have no longer any contact with. it was on my hard drive and i just pulled it out.

Well, you need the server-side script from somewhere. There are plenty of contact form processing scripts out there (some are very old and dodgy), which you could adapt to our existing form. However, if you don’t know any PHP of JavaScript, you’d be better off using a non-ajax form and a simple form processing script on the server site - a “drag and drop” solution.

i have relative knowledge of php and im comfortable with javascript. i just need some sort of example on writing something for this. i got another contact.php file ready but not sure how to adapt it to this.

$name = $_POST['name'];
$message = $_POST['message'];
$email = $_POST['email'];
$email_regex = '/.../'; // some regular expression to match against

if ($message && $name && preg_match($email_regex, $email)) {
  $result = mail('me@domain.com', $message, $email); // or whatever order they go in
}
if ($result) echo '1'; // your ajax request would receive '1' if the procedure was successful. Then you could display your "success" message

That’s an extremely simplistic approach and you would need to do more sanitising of the inputted information. You could even use a service like Akismet to find out if it is a spam message. You should also do this checking on the client side, to inform the user if something is wrong so that they don’t have to make a trip to the server to find this out. In addition, this procedure should also cater for if the form was submitted normally (i.e. not as an ajax request).

But that’s basically it, not too complicated a script.

alright thanks