Results 1 to 3 of 3

Thread: I need urgent help

  1. #1
    Join Date
    Sep 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I need urgent help

    Am new to PHP programming, and am faceing this problems:
    I need urgent assistance to this php code (contact.php) to submit form values.
    below are both the CONTACT.HTML code and CONTACT.PHP codes.


    CONTACT.HTML CODE

    <form name="form1" method="post" action="contact.php">
    <table width="92%" height="339" border="0" align="center">
    <tr>
    <td width="28%" height="30"><div align="right" class="style2">First
    Name</div></td>
    <td width="72%"><div align="left">
    <input name="First _Name" type="text" id="First _Name">
    </div></td>
    </tr>
    <tr>
    <td height="40"><div align="right" class="style2">Last
    Name</div></td>
    <td> <div align="left">
    <input name="Last_Name" type="text" id="Last_Name">
    </div></td>
    </tr>
    <tr>
    <td height="34"><div align="right" class="style2">E-mail</div></td>
    <td> <div align="left">
    <input name="Email" type="text" id="Email">
    </div></td>
    </tr>
    <tr>
    <td height="44"><div align="right" class="style2">Phone
    </div></td>
    <td> <div align="left">
    <input name="Phone" type="text" id="Phone">
    </div></td>
    </tr>
    <tr>
    <td height="47"><div align="right" class="style2">Subject</div></td>
    <td> <div align="left">
    <input name="Subject" type="text" id="Subject">
    </div></td>
    </tr>
    <tr>
    <td align="right" valign="top"><div align="right"><span class="style2">message</span></div></td>
    <td><textarea name="Message" cols="40" rows="6" id="Message"></textarea></td>
    </tr>
    </table>
    <br>
    <p align="center">&nbsp;</p>
    <p align="center">
    <input type="submit" name="Submit" value="Submit">
    &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input name="Reset" type="reset" id="Reset" value="Reset">
    </p>
    </form>




    CONTACT.PHP CODE
    <?php
    $error_occured = "no";
    if (isset($_POST['submit'])){
    $First_Name = $_POST['First_Name']; // getting the value of first name
    $Last_Name = $_POST['Last_Name']; // getting the value of last name
    $Email = $_POST['Email']; // getting the value of E-mail
    $Phone = $_POST['Phone']; // getting the value of Phone number
    $Subject = $_POST['Subject']; // getting the value of Subject
    $Message = $_POST['Message']; // getting the value of user Message
    }


    if($error_occured=="no") {

    $mailto = "info@charismaticbelieverschurchinternational.com";
    $email_from = email_address;
    echo "your message has been delivered successfully. Thank you.";
    }
    ?>

    WHEN EVER I CLICK THE SUBMIT BUTTON I RECIEVE THE DELEVERY MESSAGE BUT I DON'T GET THE MESSAGE ON THE WEB MAIL.

    THANKS

  2. #2
    Join Date
    Apr 2006
    Posts
    190
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default

    Your not telling it to do anything.

    Look here on how to email with PHP http://us.php.net/mail
    Ryan
    Sevierville, TN

  3. #3
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    Try this:

    Code:
    <?php
    
    if (isset($_POST['submit'])){
    
    	$First_Name = $_POST['First_Name']; // getting the value of first name
    	$Last_Name = $_POST['Last_Name']; // getting the value of last name
    	$Email = $_POST['Email']; // getting the value of E-mail
    	$Phone = $_POST['Phone']; // getting the value of Phone number
    	$Subject = $_POST['Subject']; // getting the value of Subject
    
    	$to = "info@charismaticbelieverschurchinternational.com";
    
    	$message = "From : $First_Name $Last_Name\n";
    	$message .= "Phone : $Phone\n";
    	$message .= $_POST['Message'];
    
    	$from  = $Email;
    
    	if ( mail($to, $Subject, $message, $from) ) { // This line is the key to sending an email. Without it, no email will ever be sent
    
    		echo "<p>Your message has been delivered successfully. Thank you.</p>";
    
    	} else {
    
    		echo "<p>There was a problem.</p>";
    
    	}
    
    }
    
    ?>
    I got rid of your $error_occurred variable because it is not doing anything in your script.

    I would recommend validating all of the information your users are providing in the form too. Especially the email address. You could use the code below to check if the user provided a valid email address.

    Code:
    if ( preg_match('/^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/', $_POST['Email']) ) {
    	
    		$from = $_POST['Email'];
    	
    	} else {
    	
    		echo '<p class="error">Please provide a valid email address.</p>';
    	
    	}
    Good luck!

    Jason

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •