Jump to content


Photo

contact form doesn't work, came with script


  • Please log in to reply
2 replies to this topic

#1 Colleen78

Colleen78
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts
  • LocationCanada

Posted 11 September 2006 - 05:46 AM

I am wondering if anyone can see why this doesn't work, when you use it, nothing happens.

<?
require_once("conn.php");
include_once "templates/MainHeader.php";

if(isset($submit))
{
	if(!empty($_POST[name]))
	{
		$name1 = strip_tags($_POST[name]);
	}
	else
	{
		echo "<p align=\"center\"><font size=\"2\" face=\"Arial, Helvetica, sans-serif\">You did not enter your name.</p>";
	}

	if(!empty($_POST[email]))
	{
		$email1 = strip_tags($_POST[email]);
	}
	else
	{
		echo "<p align=\"center\"><font size=\"2\" face=\"Arial, Helvetica, sans-serif\">You did not enter your email address.</p>";
	}

	if(!empty($_POST[subject]))
	{
		$subject1 = strip_tags($_POST[subject]);
	}
	else
	{
		echo "<p align=\"center\"><font size=\"2\" face=\"Arial, Helvetica, sans-serif\">The subject field is empty.</p>";
	}

	if(!empty($_POST[message]))
	{
		$message1 = strip_tags($_POST[message]);
	}
	else
	{
		echo "<p align=\"center\"><font size=\"2\" face=\"Arial, Helvetica, sans-serif\"> You did not write a message.</p>";
	}

	if(!empty($name1) && !empty($email1) && !empty($subject1) && !empty($message1))
	{
		//I use the email for official corespondence
		$to = "$_SERVER[HTTP_HOST] <$aset[ContactEmail]>";

		//display the message author and his email
		$from = "From: $name1 <$email1>";

		//this subject will be visible only for you
		$sub = "Contact form message - JokeMadness";

		//fit together all the post information into one message
		$message = "$subject1 \n\n"."$message1 \n\n"."$name1\n";

		//if a user has insert some html/javascript/php tags
		//we will remove them for security reasons
		$message = stripslashes($message);

		//now send the message
		mail($to, $sub, $message, $from);


		//display "thank you" message. You can edit it and write what you want.
		//if you want to use quotes at this message, use this format:     \"text here\"
		//you can use any html tags
		echo "<p align=\"center\"><font size=\"2\" face=\"Arial, Helvetica, sans-serif\"><br />Thanks for your message. <br />We will contact you as soon as possible.</p>";
		include_once ("templates/MainFooter.php");
		exit();
	}
	
}

?>
<br />
<form method="post" action="">
<fieldset>
<legend>Contact Us</legend>
<table border="0" cellspacing="2" cellpadding="5">
    <tr> 
      <td colspan="2"><b>Note:</b> all fields are required.<br /></td>
	</tr>
          <tr> 
            <td>Your name:</td>
            <td> <input type="text" name="name" /></td>
          </tr>
          <tr> 
            <td>Your email:</td>
            <td> <input type="text" name="email" /></td>
          </tr>
          <tr> 
            <td>Subject:</td>
            <td> <input type="text" name="subject" /></td>
          </tr>
          <tr> 
            <td valign="top">Message:</td>
            <td> <textarea name="message" rows="4" cols="30"></textarea></td>
          </tr>
          <tr> 
            <td colspan="2" align="center"><input type="submit" name="submit" class="SRT" value="Send" /> 
              &nbsp;&nbsp;&nbsp; <input type="reset" class="SRT" /></td>
  </tr>
</table>
</fieldset>
</form>
<?php include_once ("templates/MainFooter.php"); ?>

If you can help me pinpoint the problem, excellent! I've been trying to figure it out for days. There's no errors, nothing. I've even removed the includes to see what happens and it still doesn't work so it's not the templates either.

#2 kayess2004

kayess2004
  • Members
  • PipPip
  • Member
  • 18 posts
  • LocationAustralia

Posted 11 September 2006 - 06:21 AM

Hi,
try changing the following :

if(isset($submit))
{
to
if(isset($_POST['submit']))
{

See how you go.

HTH
Chuck Norris doesn't know love. Chuck Norris only knows not kill.

#3 Colleen78

Colleen78
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts
  • LocationCanada

Posted 11 September 2006 - 10:26 PM

That did the trick! Thanks so much! I wish I'd seen that. :D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users