PDA

View Full Version : Autoresponder for form



Pazza
15-08-2008, 11:13 PM
Hey, I have a PHP form.

There is a default from e-mail, dunno what it is. But, autoresponders arent working for the form. So is there any way to do it.

+rep for help

RSTurbo
15-08-2008, 11:21 PM
Excellant is your best bet he helped me with my PHP form :)

Good luck.

Excellent1
15-08-2008, 11:42 PM
Hey, I have a PHP form.

There is a default from e-mail, dunno what it is. But, autoresponders arent working for the form. So is there any way to do it.

+rep for helpMake sure you're using headers too:

$headers = "From: [email protected]"; This way we show who the email is from.
Oh also, on the mail(); function, include $headers into there, should be fine.

Pazza
16-08-2008, 03:29 PM
Make sure you're using headers too:

$headers = "From: [email protected]"; This way we show who the email is from.
Oh also, on the mail(); function, include $headers into there, should be fine.

Oh BTW its your form xD

Erm... I'll try and see :), makin' backup cos I know i'll mess up :P

Pazza
16-08-2008, 03:55 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>BobbaFM Staff Applications</title>
</head>

<body background="habbo.gif">
<center>Please only send 1 application, however you may send another if you do not get through, this time?
<p>
<p>
<?php
if(isset($_POST['send'])) { //Checks if the applicant has submitted the form.

if((!$_POST['email']) || (!$_POST['name']) || (!$_POST['sub']) || (!$_POST['job'])) { //Make sure they have filled in all fields.

echo "Some fields have been left blank, please go back and refill them!"; //Display the error.
} //End the check on the fields.

else //Maybe..

{
$email = addslashes(htmlspecialchars($_POST['email'])); //Removes the slashes.
$name = addslashes(htmlspecialchars($_POST['name']));
$sub = addslashes(htmlspecialchars($_POST['sub']));
$job = addslashes(htmlspecialchars($_POST['job']));

$mail = "[email protected]"; //Change this to the the email you want the message to go to.
$subject = "$name with the e-mail: $email has applied for the job: $job !"; //Displays the name and the job in the email subject.
$mess = "Heres their details:
<p>Name: $name
<br>Email: $email
<br>Job: $job
<br>Why we should choose them:
<br>$sub";

mail("$mail","$subject","$mess"); //We use the mail(); function to send the email.

echo "Your application has been sent, we will reply within 48 hours!"; //Hooharr! Success!
} //End the else.
} // End the post.

else //Form time!

{

echo "<form method='post' action='$_SERVER[PHP_SELF]'>
Email:<br>
<input type='text' name='email' size='30'><br>
Name:<br>
<input type='text' name='name' size='30'><br>
Job:<br>
<select name='job' size='1'>
<option value='Radio manager' value='Radio manager'>Radio manager (x3)</option>
<option value='Head DJ' value='Head DJ'>Head DJ (x6)</option>
<option value='DJ' value='DJ'>DJ (x12)</option>
<option value='News Manager' value='News Manager'>News Manager (x2)</option>
<option value='Senior Reporter' value='Senior Reporter'>Senior Reporter (x4)</option>
<option value='News Reporter' value='News reporter'>News reporter (x12)</option>
</select><br>
Why we should choose you (In as much detail as possible)<br>
<textarea name='sub' cols='45' rows='6'>If your application doesn't fill this, you don't have a chance :)</textarea><br>
<input type='submit' name='send' value='Submit'></form>";
//You can change these values or whatever, have fun.

} //End the last else.
?>
</center>
</body>
</html>
Tahts my code(Made by excellent) I don't get where to put them in :S

Excellent1
16-08-2008, 05:38 PM
Use this (with headers, change the email):

<?php
if(isset($_POST['send'])) { //Checks if the applicant has submitted the form.

if((!$_POST['email']) || (!$_POST['name']) || (!$_POST['sub']) || (!$_POST['job'])) { //Make sure they have filled in all fields.

echo "Some fields have been left blank, please go back and refill them!"; //Display the error.
} //End the check on the fields.

else //Maybe..

{
$email = addslashes(htmlspecialchars($_POST['email'])); //Removes the slashes.
$name = addslashes(htmlspecialchars($_POST['name']));
$sub = addslashes(htmlspecialchars($_POST['sub']));
$job = addslashes(htmlspecialchars($_POST['job']));

$mail = "[email protected]"; //Change this to the the email you want the message to go to.
$subject = "$name has applied for the $job job!"; //Displays the name and the job in the email subject.
$headers = "From: [email protected]";
$mess = "Heres their details:
Name: $name
Email: $email
Job: $job
Message:
$sub";

mail("$mail","$subject","$mess","headers"); //We use the mail(); function to send the email.

echo "Your application has been sent, we will reply within 2-3 working days!"; //Hooharr! Success!
} //End the else.
} // End the post.

else //Form time!

{

echo "<form method='post' action='$_SERVER[PHP_SELF]'>
Email:<br>
<input type='text' name='email' size='30'><br>
Name:<br>
<input type='text' name='name' size='30'><br>
Job:<br>
<select name='job' size='1'>
<option value='Radio manager' value='Radio manager'>Radio manager</option>
<option value='DJ' value='DJ'>DJ</option>
<option value='News team' value='News team'>News team</option>
<option value='Graphics team' value='Graphics team'>Graphics team</option>
<option value='Forum MOD' value='Forum MOD'>Forum MOD</option>
<option value='Alterations team' value='Alterations team'>Alterations team</option>
<option value='Forum Manager' value='Forum Manager'>Forum Manager</option>
</select><br>
Message:<br>
<textarea name='sub' cols='45' rows='6'></textarea><br>
<input type='submit' name='send' value='Submit'></form>";
//You can change these values or whatever, have fun.

} //End the last else.
?>

Pazza
16-08-2008, 06:26 PM
Will the 'headers' change to the e-mail the applicant puts in, so the autoresponse goes to that address?

Excellent1
16-08-2008, 06:36 PM
Will the 'headers' change to the e-mail the applicant puts in, so the autoresponse goes to that address?Here, under the echo "Your application has been sent, we will reply within 48 hours!";
put:

$email = "$email";
$message = "Lol, thanks for submitting the form!! Whatever blah";
$headers = "From: [email protected]";
mail("$email","$message","$headers");
This will then send them and email once they have submitted the form.

Pazza
16-08-2008, 06:43 PM
Just testing it now :)

Excellent1
16-08-2008, 06:47 PM
Let me know if it works out.

Pazza
16-08-2008, 06:55 PM
IT WORKS :D

I also amazed myself by putting $job in the e-mail, saying what they applied for.

+rep :D

EDIT - Can't, I owe :)

Excellent1
16-08-2008, 06:56 PM
IT WORKS :D

I also amazed myself by putting $job in the e-mail, saying what they applied for.

+rep :D

EDIT - Can't, I owe :)Haha, well done.

Pazza
16-08-2008, 06:58 PM
loool

Since ur good at PHP, what helped u learn it?

Also, I'm annoying you now, but how do I make it so If they select Radio manager, it comes up with form for that, news manager form for that etc.

Want to hide these adverts? Register an account for free!