Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Question regarding to sendmail.php

the mail() function

Moderators: macek, egami, gesf

Question regarding to sendmail.php

Postby stevesujk32 » Tue Aug 30, 2011 2:00 am

Hello all,

I am a beginner to php.

I need some help with my sendmail.php file.


Following is code of the contact form
Code: Select all
<form id="contact1" name="contact1" method="post" action="../sendmail.php">
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
           <td width="20%" height="30" align="left" valign="middle"><span style=" font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#333333;">Name:</span></td>
           <td width="80%" height="30" align="center" valign="middle"><input type="text" name="name" id="name" style="width:90%; font-family:Verdana, Geneva, sans-serif;" /></td>
         </tr>
        <tr>
           <td width="20%" height="30" align="left" valign="middle"><span style=" font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#333333;">Number:</span></td>
           <td width="80%" height="30" align="center" valign="middle"><input type="text" name="number" id="number" style="width:90%; font-family:Verdana, Geneva, sans-serif;" /></td>
         </tr>
         <tr>
           <td width="20%" height="30" align="left" valign="middle"><span style=" font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#333333;">Email:</span></td>
           <td width="80%" height="30" align="center" valign="middle"><input type="text" name="email" id="email" style="width:90%; font-family:Verdana, Geneva, sans-serif;" /></td>
         </tr>
         <tr>
           <td width="20%" height="30" align="left" valign="middle"><span style=" font-family:Verdana, Geneva, sans-serif; font-size:11px; color:#333333;">Subject:</span></td>
           <td width="80%" height="30" align="center" valign="middle">
               <select name="select" id="select" style="width:90%; font-family:Verdana, Geneva, sans-serif;">
                 <option value="GeneralEnquiry">General Enquiry</option>
                 <option value="Business Enquiry">Business Enquiry</option>
                 <option value="Other Enquiry">Other Enquiry</option>
                 </select>
             </td>
         </tr>
        <tr>
           <td height="30" align="left" valign="middle">&nbsp;</td>
           <td height="30" align="right" valign="middle" style="padding-right:15px;">
               <input name="submit" type="submit" id="submit" style="font-family:Verdana, Geneva, sans-serif;" onclick="MM_validateForm('name','','R','number','','R','email','','R');return document.MM_returnValue" value="Submit"/>
               </td>
        </tr>
   </table>
</form>


sendmail.php file
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

   <?php
   $to = "stevesujk32@msn.com";
   $subject = "Client Contact";
   $name = $_REQUEST['name'] ;
     $number = $_REQUEST['number'] ;
     $email = $_REQUEST['email'] ;
     $select = $_REQUEST['select'] ;
   $from = $email;
   $headers = "From:" . $email;
   mail($to,$subject,$message,$headers);
   echo "Mail Sent.";
   ?>
</body>
</html>


Also, does anyone know how to do redirection. I have try the code "header( 'Location: http://www.google.com' )" but it returns with error.

Can any please help me on this.

Thank you all.

Sincerely,

Steve
stevesujk32
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue Aug 30, 2011 1:50 am

Re: Question regarding to sendmail.php

Postby subhrakiit » Tue Aug 30, 2011 7:22 am

1. R u running this mail code in your localhost?
2. If U r running in your localhost, then r u running mail server in ur localhost?
subhrakiit
New php-forum User
New php-forum User
 
Posts: 6
Joined: Sun Dec 19, 2010 11:53 pm

Re: Question regarding to sendmail.php

Postby stevesujk32 » Tue Aug 30, 2011 7:06 pm

Thank you for the reply.

I am doing the testing on remote server.

The main issue is that I can receive an email that sent from the form, but with no content in it.

About the Redirection error, it is an different sendmail.php file.

I am not able to show you the error message now, but basically, it just tells you which line of the code in the .php file is having error.

And the line of error is the redirection code "header( 'Location: http://www.google.com' )" .

Hope it is enough information.

Thank you

Steve
stevesujk32
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue Aug 30, 2011 1:50 am


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron