Alright, so basic story, is a website, with an application form, and what im trying to do, is when the user presses the "submit" button, i get an email with all of the information they entered into the field, i *almost* had it working, almost being, when pressing the "submit" button, i would get an email, it would tell me who it was from, and give me my desired subject line, but the email would be completely blank, with no information from the form.

This is a website for a local music festival, prior to this i had next to no experience with any kind of HTML, PHP, etc. Please keep that in mind with replies :).

Im assuming there is something wrong with my mail() script, just not sure exactly what.

Here is my PHP code:

<?php
 

<!---Requesting variables from the source HTML file----->

  $groupname = $_REQUEST['groupname'] ;
  $info = $_REQUEST['info'] ;
  $size = $_REQUEST['size'] ;
  $special = $_REQUEST['special'] ;
  $firstname =$_REQUEST['firstname'] ;
  $lastname = $_REQUEST['lastname'] ;
  $address1 = $_REQUEST['address1'] ;
  $address2 = $_REQUEST['address2'] ;
  $city = $_REQUEST['city'] ;
  $prov = $_REQUEST['prov'] ;
  $email = $_REQUEST['email'] ;
  $phone1 = $_REQUEST['phone1'] ;
  $phone2 = $_REQUEST['phone2'] ;
  $phone3 = $_REQUEST['phone3'] ;
  $website = $_REQUEST['website'] ;
  

  

  mail( "user@mailserver.com", "Vendor Application",
    $message, "From: $email" );
  header( "Location: http://www.thewebsiteimlinkingto.ca/thanks!.html" );
  
  
?>

Side note: The $message portion in the mail() was originally, all of the variables from above, separated by commas, so $group, $info, $size, .... etc. That is where i had blank emails coming in. I was playing around with different ideas, and nothing worked.

The relevant code for the form:

<!-----Start Form--->
       <hr>
       
       <br>
       <br>
       <br>
       <br>
     
        
        <form align=left id="myform" method="post" action="send.php">
        
  Name of Company, Individual, or group*: <input type="text" size="15" maxlength="40" name="groupname"> <br/>
  
 Describe what you sell, or the service you provide*: <br/>
 <textarea rows="10" cols="30" wrap="physical" name="info">Please Describe your group here....(you can adjust the size of the window by clicking and dragging on the lower right corner!)</textarea><br/> 
 
 Our booths are 10x10, and you can request either powered or unpowered. Select "other" if these do not fit your needs, and let us know in the special requirements!*<br/>
 
 <input type="radio" name="size" value="10x10unpowered">10x10 Unpowered $50<br/>
 <input type="radio" name="size" value="10x10powered"> 10x10 Powered $75<br/>
 <input type="radio" name="size" value="other"> Other<br/>
        
 Describe any special requirements: <br/>
 <textarea rows="10" cols="30" wrap="physical" name="special"> Please describe any special requirements you may have</textarea>       
        <br>
 Contact Name*: <input type="text" size="15" maxlength="15" name="firstname"> Last Name*: <input type="text" size="15" maxlength="15" name="lastname"><br/><br/>
 
 Address line 1*:
 <input type="text" size="15" maxlength="40" name="address1"> <br/>
 Address line 2: <input type="text" size="15" maxlength="40" name="adress2"><br/>
 
 City*: <input type="text" size="10" maxlength="15" name"city">  
 
 <br/>
 <br/>
Province\Territory*: <select name="prov">
<option> Choose One</option>
<option> Alberta</option>
<option> British Columbia</option>
<option> Manitoba</option>

<option> New Brunswick</option>
<option> Newfoundland & Labrador</option>
<option> North West Territories</option>
<option> Nova Scotia</option>

<option> Nunavut</option>
<option> Ontario</option>
<option> Quebec</option>

<option> Prince Edward Island</option>
<option> Saskatchewan</option

<option> Yukon</option>
 
 </select>
<br/>
<br/>

Email*:<input type="text" size="15" maxlength="30" name="email"><br>

Phone Number: <input type="text" size="4" maxlength="3" name="phone1"> - <input type="text" size="4" maxlength="3" name="phone2"> - <input type="text" size="5" maxlength="4" name="phone3">
<br>
<br>
  
  
Website Address:<input type="text" size="15" maxlength="50" name="website">
<br>

<input type="submit" name="submit" value="Submit">
        </form> 
        <!---------End Form------>

Recommended Answers

All 7 Replies

Ok, so i solved my initial issue. Managed to get the submission button to actually send an email with all the fields that i wanted.

$message = "$groupname, $info, $size, $special, $firstname, $lastname, $address1, $adress2, $city, $prov, $email, $phone1, $phone2, $phone3, $website" ;

  mail( "myemail@here.com", "Vendor Application",
    $message, "From: $email" );
  header( "Location: http://www.website.ca/thanks.html" );

Next issue that im beating my face against is the output, which looks like this: (actually sent from the form...i was being random)

"Awesomenes, Were awesome, 10x10powered, AWESOMEFACTOR TIMES A MILLION, awesome, mcawesomness, a;lkjdf, , , Saskatchewan, awesome@awesomeus.ca, , , , "

where each comma represents a unique field. The last ones, i didnt include a phone number, or a website.

Next question is, can i make it look cleaner, where the title of each field being answered is above, and the user's response, a line lower, so it breaks it up nicer, and makes it easier to read long entries?

HI

Pls check the below code

Line 31

Address line 2: <input type="text" size="15" maxlength="40" name="address2"><br/>

LIne 33

City*: <input type="text" size="10" maxlength="15" name="city">

Formatted email

<?php


  $groupname = $_REQUEST['groupname'] ;
  $info = $_REQUEST['info'] ;
  $size = $_REQUEST['size'] ;
  $special = $_REQUEST['special'] ;
  $firstname =$_REQUEST['firstname'] ;
  $lastname = $_REQUEST['lastname'] ;
  $address1 = $_REQUEST['address1'] ;
  $address2 = $_REQUEST['address2'] ;
  $city = $_REQUEST['city'] ;
  $prov = $_REQUEST['prov'] ;
  $email = $_REQUEST['email'] ;
  $phone1 = $_REQUEST['phone1'] ;
  $phone2 = $_REQUEST['phone2'] ;
  $phone3 = $_REQUEST['phone3'] ;
  $website = $_REQUEST['website'] ;
  
$message = "<table width='600px' border="0" cellspacing='3' cellpadding='3'>
  <tr>
    <td><strong>Groupname :</strong></td>
    <td>$groupname</td>
  </tr>
  <tr>
    <td><strong>Info :</strong></td>
    <td>$info</td>
  </tr>
  <tr>
    <td><strong>Size :</strong></td>
    <td>$size</td>
  </tr>
  <tr>
    <td><strong>Special :</strong></td>
    <td>$special</td>
  </tr>
  <tr>
    <td><strong>Firstname :</strong></td>
    <td>$firstname</td>
  </tr>
  <tr>
    <td><strong>Lastname :</strong></td>
    <td>$lastname</td>
  </tr>
  <tr>
    <td><strong>Address1 :</strong></td>
    <td>$address1</td>
  </tr>
  <tr>
    <td><strong>Address2 :</strong></td>
    <td>$address2</td>
  </tr>
  <tr>
    <td><strong>City :</strong></td>
    <td>$city</td>
  </tr>
  <tr>
    <td><strong>Prov :</strong></td>
    <td>$prov</td>
  </tr>
  <tr>
    <td><strong>Email :</strong></td>
    <td>$email</td>
  </tr>
  <tr>
    <td><strong>Phone1 :</strong></td>
    <td>$phone1</td>
  </tr>
  <tr>
    <td><strong>Phone2 :</strong></td>
    <td>$phone2</td>
  </tr>
  <tr>
    <td><strong>Phone3 :</strong></td>
    <td>$phone3</td>
  </tr>
  <tr>
    <td><strong>Website :</strong></td>
    <td>$website</td>
  </tr>
</table>" ;
  $headers  = "From: ".$email."\r\n";
  $headers .= 'MIME-Version: 1.0' . "\n";
  $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	
  mail( "user@mailserver.com", "Vendor Application",
    $message, $headers );
  header( "Location: http://www.thewebsiteimlinkingto.ca/thanks!.html" );
  
  
?>

Hi

vibhadevit had made your thing simple.

Thanks Vibhadevit! didnt think of setting up tables! Only thing is, and this goes back to my in-experience using PhP, is when i try to send it, i get the following error

"Parse error: syntax error, unexpected T_LNUMBER in D:\Hosting\7839877\html\apps\Vendorapp\send.php on line 20"

i tried replacing the single quotes with doubles, didn't help anything. Not sure what i can do to fix the code.

Don't replace the single quote with doubles, in line 20, the issue is with the double quotes in border="0". Those should be changed to single quotes, as seen here:

<?php


  $groupname = $_REQUEST['groupname'] ;
  $info = $_REQUEST['info'] ;
  $size = $_REQUEST['size'] ;
  $special = $_REQUEST['special'] ;
  $firstname =$_REQUEST['firstname'] ;
  $lastname = $_REQUEST['lastname'] ;
  $address1 = $_REQUEST['address1'] ;
  $address2 = $_REQUEST['address2'] ;
  $city = $_REQUEST['city'] ;
  $prov = $_REQUEST['prov'] ;
  $email = $_REQUEST['email'] ;
  $phone1 = $_REQUEST['phone1'] ;
  $phone2 = $_REQUEST['phone2'] ;
  $phone3 = $_REQUEST['phone3'] ;
  $website = $_REQUEST['website'] ;
  
$message = "<table width='600px' border='0' cellspacing='3' cellpadding='3'>
  <tr>
    <td><strong>Groupname :</strong></td>
    <td>$groupname</td>
  </tr>
  <tr>
    <td><strong>Info :</strong></td>
    <td>$info</td>
  </tr>
  <tr>
    <td><strong>Size :</strong></td>
    <td>$size</td>
  </tr>
  <tr>
    <td><strong>Special :</strong></td>
    <td>$special</td>
  </tr>
  <tr>
    <td><strong>Firstname :</strong></td>
    <td>$firstname</td>
  </tr>
  <tr>
    <td><strong>Lastname :</strong></td>
    <td>$lastname</td>
  </tr>
  <tr>
    <td><strong>Address1 :</strong></td>
    <td>$address1</td>
  </tr>
  <tr>
    <td><strong>Address2 :</strong></td>
    <td>$address2</td>
  </tr>
  <tr>
    <td><strong>City :</strong></td>
    <td>$city</td>
  </tr>
  <tr>
    <td><strong>Prov :</strong></td>
    <td>$prov</td>
  </tr>
  <tr>
    <td><strong>Email :</strong></td>
    <td>$email</td>
  </tr>
  <tr>
    <td><strong>Phone1 :</strong></td>
    <td>$phone1</td>
  </tr>
  <tr>
    <td><strong>Phone2 :</strong></td>
    <td>$phone2</td>
  </tr>
  <tr>
    <td><strong>Phone3 :</strong></td>
    <td>$phone3</td>
  </tr>
  <tr>
    <td><strong>Website :</strong></td>
    <td>$website</td>
  </tr>
</table>" ;
  $headers  = "From: ".$email."\r\n";
  $headers .= 'MIME-Version: 1.0' . "\n";
  $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	
  mail( "user@mailserver.com", "Vendor Application",
    $message, $headers );
  header( "Location: http://www.thewebsiteimlinkingto.ca/thanks!.html" );
  
  
?>

Hope this helps! :)

Yeah i forget to replace that double quote to single.
Generally when you are using editor( i use dream weaver ) if string is not completed proper you can see color change.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.