PHP Contact Form: I will pay you to finish it for me!

Discussion in 'PHP' started by redgsr, Dec 1, 2006.

  1. #1
    I have just about finished a very simple PHP contact form but I can't get it to work right.

    I will give someone a few bucks if they can straighten it out for me.

    Should only take a few minutes for someone with experience.

    Below is the contact form HTML and the link to what it looks like.

    http://www.bulldogsale.net/contact.php


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Email Form </title>
    </head>
    <body>

    <center>
    <form method="post" action="sendeail.php">

    <!-- DO NOT change ANY of the php sections -->

    <input type="hidden" name="ip" value="69.250.98.26" />
    <input type="hidden" name="httpref" value="" />
    <input type="hidden" name="httpagent" value="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; MediaPilot;

    MediaPilotAd; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727)" />


    Bulldog Breed: <br />
    <input type="text" name="visitor" size="35" />
    <br />
    <br />

    Price:<br />
    <input type="text" name="visitormail" size="35" />
    <br />
    <br />

    Description 350 Character Max:<br />
    <textarea name="notes" rows="4" cols="40"></textarea>
    <br />
    <br />

    Location, State:<br />
    <input type="text" name="visitormail" size="35" />
    <br />
    <br />

    Your Email:<br />
    <input type="text" name="visitormail" size="35" />
    <br />
    <br />
    Your Website Address:<br />
    <input type="text" name="visitormail" size="35" />
    <br />
    <br />

    Your First Name:<br />
    <input type="text" name="visitormail" size="35" />
    <br />
    <br />

    Your Last Name:<br />
    <input type="text" name="visitormail" size="35" />
    <br />
    <br />

    <input type="submit" value="Send Mail" /><br />


    </form>
    </center>

    </body>
    </html>


    This is the PHP that need to be fixed to match the Contact Form above.


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Sendemail Script</title>
    </head>
    <body>

    <!-- Reminder: Add the link for the 'next page' (at the bottom) -->
    <!-- Reminder: Change 'YourEmail' to Your real email -->

    <?php
    if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
    {
    echo "<h2>Use Back - Enter valid e-mail</h2>\n";
    $badinput = "<h2>Feedback was NOT submitted</h2>\n";
    echo $badinput;
    }
    if(empty($visitor) || empty($visitormail) || empty($notes )) {
    echo "<h2>Use Back - fill in all fields</h2>\n";
    }

    $todayis = date("l, F j, Y, g:i a") ;

    $attn = $attn ;
    $subject = $attn;

    $notes = stripcslashes($notes);

    $message = " $todayis [EST] \n
    Attention: $attn \n
    Message: $notes \n
    From: $visitor ($visitormail)\n
    Additional Info : IP = $ip \n
    Browser Info: $httpagent \n
    Referral : $httpref \n
    ";

    $from = "From: $visitormail\r\n";


    mail("sales@danielmillions.com", $subject, $message, $from);

    ?>

    <p align="center">
    Date: <?php echo $todayis ?>
    <br />
    Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
    <br />

    Attention: <?php echo $attn ?>
    <br />
    Message:<br />
    <?php $notesout = str_replace("\r", "<br/>", $notes);
    echo $notesout; ?>
    <br />
    <?php echo $ip ?>

    <br /><br />
    <a href="contact.php"> Next Page </a>
    </p>

    </body>
    </html>



    All the info from the contact form is supposed to go to my email account.

    Thanks for the help.
     
    redgsr, Dec 1, 2006 IP
  2. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I just glanced at it (didn't read it at all :() but it looks like register globals is off. Every variable you're taking from the form, do this to it:

    Was: $visitoremail
    Now: $_POST['visitoremail']

    More on php.net
     
    CodyRo, Dec 1, 2006 IP
  3. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #3
    I think you're looking for :

    
    <?
    
    $sysmail = "you@yourdomain.com"; // The email to spit messages @
    
    if ($_POST)
    {
    	if($_POST['visitormail'] == "" || !preg_match("/^.*?@.*?$/si", $_POST['visitormail']))
    	{
    		$msgs .= "<b>Enter valid e-mail</b><br>\n"
    			    ."<b>Feedback was NOT submitted</b>\n";
    	}
    	if ($msgs == "")
    	{
    		foreach ($_POST as $key => $value)
    		{
    			if ( $key != "visitorweb" )
    			{
    				if (empty($value))
    				{
    					$msgs .= "<b>$key is required<b><br>\n";
    				}
    			}
    		}
    	}
        if ($msgs == "")
        {
      	  $message = "". date("l, F j, Y, g:i a") ." [EST] \n".
    	  "Message: ". stripslashes(trim($_POST['notes'])) ."\n".
    	  "From : ". $_POST['first'] . " " . $_POST['last'] . "\n".
    	  "Breed " . $_POST['bullbreed'] . "\n".
    	  "Price " . $_POST['price'] . "\n".
    	  "Location " . $_POST['state']  . "\n".
    	  "Website " . $_POST['visitorweb']  . "\n".
    	  "Additional Info : IP = " .  $_SERVER['REMOTE_ADDR'] . " \n".
    	  "Browser Info: ". $_SERVER['HTTP_USER_AGENT']  . " \n".
    	  "Referral : " . $_SERVER['HTTP_REFERER']  . "\n";
    	  if (mail("$sysmail", "New contact", $message, "From: " . $_POST['visitormail'] . "\r\n"))
    	   {
    		  $msgs .= "Mail sent";
    	   }
    	   else 
    	   {
    		   $msgs .= "Mail not sent";
    	   }
        }
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Email Form</title>
    </head>
    <body>
    <center>
      <?=$msgs ?>
      <form method="post" action="">
        Bulldog Breed: <br />
        <input type="text" name="bullbreed" size="35" />
        <br />
        Price:<br />
        <input type="text" name="price" size="35" />
        <br />
        Description 350 Character Max:<br />
        <textarea name="notes" rows="4" cols="40"></textarea>
        <br />
        Location, State:<br />
        <input type="text" name="state" size="35" />
        <br />
        Your Email:<br />
        <input type="text" name="visitormail" size="35" />
        <br />
        Your Website Address:<br />
        <input type="text" name="visitorweb" size="35" />
        <br />
        Your First Name:<br />
        <input type="text" name="first" size="35" />
        <br />
        Your Last Name:<br />
        <input type="text" name="last" size="35" />
        <br />
        <input type="submit" value="Send Mail" />
        <br />
      </form>
    </center>
    </body>
    </html>
    
    PHP:
    Have fun .....
     
    krakjoe, Dec 2, 2006 IP
  4. redgsr

    redgsr Well-Known Member

    Messages:
    1,603
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    165
    #4
    This has been resolved
     
    redgsr, Dec 2, 2006 IP