Avatar of Leroice
Leroice
 asked on

Help with PHP form

Hey guys any reason why the "sport" and "shoe" fields arent returning any results
<?php

/************************
* Variables you can change
*************************/

$mailto   = "leroice@mac.com"; // Enter your mail addres here. 
$name     = ucwords($_POST['name']); 

$email    = $_POST['email'];

$sport    = $_POST['sport'];

$shoe    = $_POST['shoe'];

$message  = $_POST['message'];

	if(strlen($_POST['name']) < 1 ){
		echo  'email_error';
	}
	
  else if(strlen($email) < 1 ) {
		echo 'email_error';
	}

  else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", $email)) {
    echo 'email_error';
  }

	else if(strlen($message) < 1 ){
		echo 'email_error';

  } else {

	// NOW SEND THE ENQUIRY

	$email_message="\n\n" .
		"Name: " .
		ucwords($name) .
		"\n" .
		"Email: " .
		$email .
		"\n" .
		"Preffered Sport: " .
		$sport .
		"\n" .
		"Shoe Size: " .
		$shoe .
		"\n" .
		"Comments: " .
		"\n" .
		$message .
		"\n" .
		"\n\n" ;

		$email_message = trim(stripslashes($email_message));
		mail($mailto, $shoe, $email_message, "From: \"$vname\" <".$email.">\nReply-To: \"".ucwords($name)."\" <".$email.">\nX-Mailer: PHP/" . phpversion() );

}
?>

Open in new window

PHP

Avatar of undefined
Last Comment
CWS (haripriya)

8/22/2022 - Mon
ploftin

You didn't include the underlying form that posts to this page, but I would suspect a problem in the form.  Verify that the fields for sport and shoe are named appropriately.  Ie.
Sport: <input type="text" name="sport" /><br />
Shoe: <input type="text" name="shoe" />

Open in new window

Leroice

ASKER
Here's the markup for the form
<!-- Contact Form Start //-->
                                      <form action="#" id="contactform"> 
                                      <fieldset>
                                      <label>Name*</label>
                                      <input type="text" name="name" class="textfield" id="name" value="Please enter both given and surnames" />
                                      <div class="clear"></div>
                                      <label>E-mail*</label>
                                      <input type="text" name="email" class="textfield" id="email" value="Please enter a valid email address" />
                                      <div class="clear"></div> 
                                      <label>Prefered Sport*</label>
                                      <input type="text" name="subject" class="textfield" id="sport" value="Enter your Favourite Sport here" />
                                      <div class="clear"></div> 
                                      <label>Shoe Size*</label>
                                      <input type="text" name="subject" class="textfield" id="shoe" value="Please indicate Men's or Women's sizing" />
                                      <div class="clear"></div>    
                                      <label>Message*</label>
                                      <textarea name="message" id="message" class="textarea" cols="2" rows="7" </textarea>
                                      <div class="clear"></div> 
                                                                      <input type="submit" name="submit" class="buttoncontact" id="buttonsend" value="Send" />
                                      <span class="loading" style="display: none;">Please wait..</span>
                                      <div class="clear"></div>
                                      <label>&nbsp;</label>
                                      *required field
                                      <div class="clear"></div>
                                      </fieldset> 
                                      </form>
                                      <!-- Contact Form End //--> 

Open in new window

ASKER CERTIFIED SOLUTION
ploftin

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Mark Brady

You named both the sports and the shoe fields "subject" that's why nothing is posted for those two fields.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
djshah

+++++
<input type="text" name="subject" class="textfield" id="sport" value="Enter your Favourite Sport here" />
                                      <div class="clear"></div>
                                      <label>Shoe Size*</label>
                                      <input type="text" name="subject" class="textfield" id="shoe" value="Please indicate Men's or Women's sizing" />
                                      <div class="clear"></div>  
+++++

Just change above code with following code:

++++
<input type="text" name="sport" class="textfield" id="sport" value="Enter your Favourite Sport here" />
                                      <div class="clear"></div>
                                      <label>Shoe Size*</label>
                                      <input type="text" name="shoe" class="textfield" id="shoe" value="Please indicate Men's or Women's sizing" />
                                      <div class="clear"></div>  
++++

It should then work. You have given name="subject" for both id="sport" and id="shoe". When form is submitted in php _POST array is build on name attribute. If name is not properly given then it will not be there in _POST array.
Mark Brady

Any reply from the asker?
Mark Brady

Hey Leroice:     Did you change your form to what we said and try it? Please let us know so we can all move on and get this question PAQ'ed

Cheers
Elvin
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Leroice

ASKER
Sorry guys haven't been online for past few days. Will have a try and let you know soon.

Thanks again for the help. It is much appreciated
p_nuts

I think the rest helped you with this one.. but a general tip..

use

print_r($_REQUEST);

to see all submitted variables to test....
sridharphp

try to write like this
if(isset($_post['submit']))
{
$comapny_name=$_POST['company_name'];//like this all  fields create
$sql="insert into tbl_users (company_name, first_name, last_name, business_street_address, business_suburb_city, business_postcode, email, phone, mobile, industry_id , username,password) values('$company_name', '$first_name', '$last_name', '$business_street_address', '$business_suburb_city', '$business_postcode', '$email', '$phone', '$mobile', '$industry', '$username','$password')";
mysql_query($sql);
header('location:samepage.php')
exit;
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
CWS (haripriya)

This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.