Jump to content


Photo

Submit Form Problem


  • Please log in to reply
1 reply to this topic

#1 laflair13

laflair13
  • Members
  • PipPipPip
  • Advanced Member
  • 86 posts

Posted 04 March 2006 - 03:15 AM

I am putting together a website for the mother and her business. She wants a contact form so customers can contect her, instead of using an email.

I got some coding together but when I submit it the email comes in blank. Can any of ya help me out on this one.

Heres a look at the codes.

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<br><br>
<form method="post" action="sendmail.php">
  Email: <input name="email" type="text" /><br />
  Name:<input type="text" name="name" size="20"><br />
  <br />
  <input type="submit" />
</form>
</body>
</html>

&

<?
  $email = $_REQUEST['email'];
  $name = $_REQUEST['name'];

  mail( "dleflair@bellsouth.net", "Link Request",
    $message, "From: $email" );
  header( "Location: <a href="http://www.example.com/thankyou.html" target="_blank">http://www.example.com/thankyou.html</a>" );
?>

There is only 2 feilds because I wanted to test it first before adding any more options. Like url, how they found her site (refered, search engine, blah, blah) which will be a drop down box.

Any help would be greatly appreciated.

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 04 March 2006 - 03:30 AM

Well, since you're not putting any text in the variable $message, you're sending anything so you will get a blank message.

Change your form to include a message box:
html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<br><br>
<form method="post" action="sendmail.php">
  Email: <input name="email" type="text" /><br />
  Name:<input type="text" name="name" size="20"><br />
  Message: <textarea name="message" colums="50" rows="10"></textarea>
  <br />
  <input type="submit" name="submit" value="Send Message"/>
</form>
</body>
</html>
And in the processing script:
<?php
  $email = $_POST['email'];
  $name = $_POST['name'];
  $message = stripslashes($_POST['message']);

  mail( "dleflair@bellsouth.net", "Link Request",
    $message, "From: $email" );
  header( "Location: http://www.example.com/thankyou.html");
?>
Note: the header() function is not a address tag, so it doesn't take any of the <a> options.

Ken





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users