View Full Version : Email Form PHP HELP~!
PichuSecretBase
November 28th, 2004, 06:21 PM
<form name="form" method="post" action="mail.php">
<p>Name: <input type="text" name="name"></p>
<p>E-Mail: <input type="text" name="email"></p>
<p>Site Name: <input type="text" name="site"></p>
<p>Site URL: <input type="text" name="url"></p>
<input type="submit" name="Submit" value="Submit">
</form>
<?php
mail("tsujichuu@comcast.net", "Exchange", $message) ;
?>
<?php
$message = "$name, $email, $site, $url" ?>
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\apachefriends\xampp\htdocs\PSB\exchange\form\mail.php on line 3
What's wrong >>
Kipkip
November 28th, 2004, 07:09 PM
You forgot to define your variables name, email, site, and url. You also needed to define the message variable before you do the mail function. Try this:
<?php
if ($HTTP_POST_VARS){
$name = $_POST['name'];
$email = $_POST['email'];
$site = $_POST['site'];
$url = $_POST['url'];
$message = 'echo "$name <br /> $email <br /> $site <br /> $url"';
mail("tsujichuu@comcast.net","Exchange",$message)
}
?>
<form name="form" method="post" action="mail.php">
<p>Name: <input type="text" name="name"></p>
<p>E-Mail: <input type="text" name="email"></p>
<p>Site Name: <input type="text" name="site"></p>
<p>Site URL: <input type="text" name="url"></p>
<input type="submit" name="Submit" value="Submit">
</form>
Call the thing mail.php or you can take the PHP code out and put it in a file called mail.php. If you do that, then take out the "if ($HTTP_POST_VARS){" and the "}" at the end. If it stills gives you problems, I try to help you out.
PichuSecretBase
November 28th, 2004, 07:30 PM
Parse error: syntax error, unexpected '}' in C:\apachefriends\xampp\htdocs\PSB\exchange\form\mail.php on line 9
I got that error
Kipkip
November 28th, 2004, 09:54 PM
Oops. Take the "}" out. That shouldn't be there. Sorry, my mistake. :P
PichuSecretBase
November 28th, 2004, 10:58 PM
Parse error: syntax error, unexpected $end in C:\apachefriends\xampp\htdocs\PSB\exchange\form\mail.php on line 10
Gahh XD
Kipkip
November 29th, 2004, 12:23 AM
<?php
if ($HTTP_POST_VARS){
$name = $_POST['name'];
$email = $_POST['email'];
$site = $_POST['site'];
$url = $_POST['url'];
mail("tsujichuu@comcast.net","Exchange","$name
$email
$site
$url");
}
?>
<form name="form" method="post" action="bob.php">
<p>Name: <input type="text" name="name"></p>
<p>E-Mail: <input type="text" name="email"></p>
<p>Site Name: <input type="text" name="site"></p>
<p>Site URL: <input type="text" name="url"></p>
<input type="submit" name="Submit" value="Submit">
</form>
That's the correct code. It'll work. If you get a blank email about this, I acciently press submit while testing it. If you get your orignal error, it maybe because it'll try to send an email using your domain and it might not work depending on your host I guess from my testing it.
PichuSecretBase
November 29th, 2004, 01:23 AM
Edit: It works on my server. Check out my PSB thread to see what I've been upto :3