Form Submission Problem

  • (2 Pages)
  • +
  • 1
  • 2

27 Replies - 900 Views - Last Post: 14 June 2013 - 08:01 AM Rate Topic: -----

#1 mattmandery  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 17-May 13

Form Submission Problem

Posted 17 May 2013 - 11:18 AM

Hello everyone this is my first post so be patient if I am asking newby questions please. I am currently designing a website and I am trying to submit info entered into a form by php submission. I have followed a few guides but I simply cannot submit the info. Some background on my problem. I am working off my local host (not on any web server but rather a folder on my desktop). Attached is my php code (1). I know for a fact in my $body all the textField values are entered correctly. However when I submit my form (which is linked to my php file and uses the POST not GET method) this is what shows up (attachment 2) for my submission screen. It is not even reading the variables in. This is what was submitted in the form values if you need to see that. (3)

Thank you in advance for any suggestions or help. I think my problem lies with using the local host and not having it posted online but again i'm very new to php and would love any help available Thanks a bunch!

Attached image(s)

  • Attached Image
  • Attached Image
  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Form Submission Problem

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 2886
  • View blog
  • Posts: 9,587
  • Joined: 12-December 12

Re: Form Submission Problem

Posted 17 May 2013 - 11:44 AM

It is more useful if you post your code (wrapped in CODE tags) rather than a screenshot.

However, the variable-names used in your HEREDOC are completely different to those declared above that: $firstName != $firstNameField. Because PHP cannot find these variables it just displays their names as is.

This post has been edited by andrewsw: 17 May 2013 - 11:45 AM

Was This Post Helpful? 0
  • +
  • -

#3 mattmandery  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 17-May 13

Re: Form Submission Problem

Posted 17 May 2013 - 11:55 AM

Forgive me if this is a dumb reply but i renamed my variables to match the ones in the single quote bracket.
<?php
/* Subject and Email Variables */
	$emailSubject = 'New Player Information to be reviewed';
	$webMaster = 'mattmandery@gmail.com';
/* Gathering Data variables */
	$firstName = $_POST['firstName'];
	$lastName = $_POST['lastName'];
	$years = $_POST['years'];
	$highSchool = $_POST['highSchool'];
	$email = $_POST['email'];
	$phone = $_POST['phone'];
	$gradYear = $_POST['gradYear'];
	$honors = $_POST['honors'];
	$info = $_POST['info'];
	
	$body = <<<EOD
<br><hr><br>
First Name: $firstName <br>
Last Name: $lastName <br>
Years Played: $years <br>
High School Attended: $highSchool <br>
Email: $email <br>
Phone Number: $phone <br>
Year Graduated: $gradYear <br>
High School Honors/Lacrosse Awards: $honors <br>
Misc Info: $info <br>
EOD;

	$headers = "From: $emailField\r\n";
	$headers .= "Content-type: text/html\r\n";
	$success = mail($webMaster, $emailSubject, $body, $headers);
/* Results rendered as HTML (Confirmed)*/
	$theResults = <<<EOD
<html>
<head>
<title>Email Confirmed</title>
</head>

<body>
Thank your for submitting your information.  Your information has been received and you will be hearing from us very shortly!  GO CARDINALS! 
</body>
</html>
EOD;
echo "$theResults";
?>



Is this what you were referencing to? I tried to submit again and it was the same outcome. Maybe im missing something....

This post has been edited by JackOfAllTrades: 17 May 2013 - 12:22 PM
Reason for edit:: Fixed code tags

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 2886
  • View blog
  • Posts: 9,587
  • Joined: 12-December 12

Re: Form Submission Problem

Posted 17 May 2013 - 12:04 PM

You almost managed to use code tags :whatsthat: but they use square brackets. Press the Preview button until it is correct.

Yes, that is what I meant. Make sure you are using your corrected file(s) and not older versions.

I don't use (avoid) DreamWeaver but there may be an option somewhere to refresh otherwise it might still be using the previous file-version(s).
Was This Post Helpful? 0
  • +
  • -

#5 mattmandery  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 17-May 13

Re: Form Submission Problem

Posted 17 May 2013 - 12:11 PM

ok thanks for the tip I will def use the code tags next time. I did what you suggested and my results are still the same. Ill post the html for my form maybe I missed something there. Also im not sure why its even Showing the variables, they are suppose to be passed into my mail() function and the only thing that should show up after I submit is a thank you message.

 <form action="mailPHP.php" method="post">
    <table border="1" bgcolor="#FFFFFF" align="center">
    <tr>
   	 	<td>First Name:</td> <td><input type="text" name="firstName"/></td>
      <br/>
    </tr>
    <tr>
    	<td>Last Name:</td> <td><input type="text" name="lastName"/></td>
	  <br/>
    </tr>
     <tr>
    	<td>Years Played:</td> <td><input type="text" name="years" id="years"/></td>
	  <br/>
    </tr>
     <tr>
    	<td>High School Attended:</td> <td><input type="text" name="highSchool"/></td>
	  <br/>
    </tr>
     <tr>
    	<td>E-mail:</td> <td><input type="text" name="email"/></td>
	  <br/>
    </tr>
     <tr>
    	<td>Phone Number:</td> <td><input type="text" name="phone" id="phone"/></td>
	  <br/>
    </tr>
    <tr>
    	<td>High School Graduation Year:</td> <td><input type="text" name="gradYear" id="gradYear"/></td>
	  <br/>
    </tr>
    <tr>
    	<td>High School Honors / Lacrosse Awards:</td> <td><textarea name="honors"></textarea></td>
	  <br/>
    </tr>
    <tr>
    	<td>Tell us about yourself:</td> <td><textarea name="info"></textarea></td>
	  <br/>
    </tr>
    
    <tr>
  	  <td><input type="submit" value="Submit Info" ></td>
      <td><input type="button" value="Clear Form" /></td>
    </tr>
    </table>
	</form>



<?php
/* Subject and Email Variables */
	$emailSubject = 'New Player Information to be reviewed';
	$webMaster = 'mattmandery@gmail.com';
/* Gathering Data variables */
	$firstName = $_POST['firstName'];
	$lastName = $_POST['lastName'];
	$years = $_POST['years'];
	$highSchool = $_POST['highSchool'];
	$email = $_POST['email'];
	$phone = $_POST['phone'];
	$gradYear = $_POST['gradYear'];
	$honors = $_POST['honors'];
	$info = $_POST['info'];
	
	$body = <<<EOD
<br><hr><br>
First Name: $firstName <br>
Last Name: $lastName <br>
Years Played: $years <br>
High School Attended: $highSchool <br>
Email: $email <br>
Phone Number: $phone <br>
Year Graduated: $gradYear <br>
High School Honors/Lacrosse Awards: $honors <br>
Misc Info: $info <br>
EOD;

	$headers = "From: $emailField\r\n";
	$headers .= "Content-type: text/html\r\n";
	$success = mail($webMaster, $emailSubject, $body, $headers);
/* Results rendered as HTML (Confirmed)*/
	$theResults = <<<EOD
<html>
<head>
<title>Email Confirmed</title>
</head>

<body>
Thank your for submitting your information.  Your information has been received and you will be hearing from us very shortly!  GO CARDINALS! 
</body>
</html>
EOD;
echo "$theResults";
?>


Think i finally got it that time :) Thanks for all the help Andrewsw

View Postmattmandery, on 17 May 2013 - 12:07 PM, said:

Think i finally got it that time :)/> Thanks for all the help Andrewsw

The code tags not the problem haha
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 2886
  • View blog
  • Posts: 9,587
  • Joined: 12-December 12

Re: Form Submission Problem

Posted 17 May 2013 - 12:15 PM

Ugg?! Where did you get the bgcolor attribute from! (and align, and border) These are deprecated, bgcolor in particular has been obsolete for a while now :dontgetit: :helpsmilie:
Was This Post Helpful? 0
  • +
  • -

#7 mattmandery  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 17-May 13

Re: Form Submission Problem

Posted 17 May 2013 - 12:18 PM

View Postandrewsw, on 17 May 2013 - 12:15 PM, said:

Ugg?! Where did you get the bgcolor attribute from! (and align, and border) These are deprecated, bgcolor in particular has been obsolete for a while now :dontgetit:/> :helpsmilie:/>

I used these because I use a CSS for my whole site making the Website background Black (one of the colors of my Lacrosse team) and I wanted to make the background color of the table white so that I can actually see the text ect.. If not bgcolor what should I define the color with?
Was This Post Helpful? 0
  • +
  • -

#8 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 2886
  • View blog
  • Posts: 9,587
  • Joined: 12-December 12

Re: Form Submission Problem

Posted 17 May 2013 - 12:27 PM

You've mentioned it: CSS! Give your table an id.

#tableid {
    background-color: #FFFFFF;
}


Erm, are you saying it is still not fixed?

If so, your HEREDOC seem messed up in previous posts, as it outputs the raw PHP. Make sure that the closing EOD; is on the far left (the very first column).
Was This Post Helpful? 0
  • +
  • -

#9 mattmandery  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 17-May 13

Re: Form Submission Problem

Posted 17 May 2013 - 12:34 PM

View Postandrewsw, on 17 May 2013 - 12:27 PM, said:

You've mentioned it: CSS! Give your table an id.

#tableid {
    background-color: #FFFFFF;
}


Erm, are you saying it is still not fixed?

If so, your HEREDOC seem messed up in previous posts, as it outputs the raw PHP. Make sure that the closing EOD; is on the far left (the very first column).


Thanks for the suggestion I went ahead and defined that stuff in my CSS. Gotta say it does look better. Thanks for that suggestion.

View Postandrewsw, on 17 May 2013 - 12:27 PM, said:

Erm, are you saying it is still not fixed?

If so, your HEREDOC seem messed up in previous posts, as it outputs the raw PHP. Make sure that the closing EOD; is on the far left (the very first column).


I just double checked and my EOD are at the very far left. I even back spaced them and re entered.
Was This Post Helpful? 0
  • +
  • -

#10 Slice  Icon User is offline

  • sudo pacman -S moneyz


Reputation: 239
  • View blog
  • Posts: 693
  • Joined: 24-November 08

Re: Form Submission Problem

Posted 17 May 2013 - 04:44 PM

Do you have php installed? At the moment it looks as if the browser is just presenting your code as plain text. If you're on a windows machine, you can install XAMPP and go to the directory : C:\xampp\htdocs\ and save your php files there.

Your second screenshot shows you accessing your file directly, however it needs to be processed via some kind of web server setup like apache (which comes with XAMPP).

Once XAMPP is up and running, you can use http://localhost/ to access your php files.

NOTE: There is also WAMP for windows, however I have no experience using it so couldn't recommend it :)
Was This Post Helpful? 1
  • +
  • -

#11 mattmandery  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 17-May 13

Re: Form Submission Problem

Posted 17 May 2013 - 05:14 PM

I did not install PHP because I figured it would be read like HTML :D/> silly me haha. Thanks for the advice. Gonna download now and try to see if it works. Not sure if you would know the answer to this but i'm planning on moving all my data to godaddy.com web hosting and I know they said they support PHP but will I need to install this again and move it to the directory? If you don't know its not a big deal. thanks again for the help! I will def be more active in the dreamincode.net community from now on. :)

This post has been edited by Dormilich: 17 May 2013 - 11:17 PM

Was This Post Helpful? 0
  • +
  • -

#12 mattmandery  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 17-May 13

Re: Form Submission Problem

Posted 17 May 2013 - 05:22 PM

[quote name='mattmandery' date='17 May 2013 - 05:14 PM' timestamp='1368836083' post='1852667']

View PostSlice, on 17 May 2013 - 04:44 PM, said:

Do you have php installed? At the moment it looks as if the browser is just presenting your code as plain text. If you're on a windows machine, you can install XAMPP and go to the directory : C:\xampp\htdocs\ and save your php files there.


When you say to move my php files to that destination do you mean all of them so its acting like a server or just that 1 php file?
Was This Post Helpful? 0
  • +
  • -

#13 Slice  Icon User is offline

  • sudo pacman -S moneyz


Reputation: 239
  • View blog
  • Posts: 693
  • Joined: 24-November 08

Re: Form Submission Problem

Posted 17 May 2013 - 05:34 PM

You need all of them there, but you also need the web server applications installed for it to work. Once installed you should be able to type http://localhost/ into your browser and get a white page that says It Works!

Edit: Sorry didn't see your first reply.

View Postmattmandery, on 18 May 2013 - 01:14 AM, said:

Not sure if you would know the answer to this but i'm planning on moving all my data to godaddy.com web hosting and I know they said they support PHP but will I need to install this again and move it to the directory?


No you won't have to install anything if you open a godaddy account. The server is already pre-configured to work with php files, you simply just upload your files and access them via your domain name.

This post has been edited by Slice: 17 May 2013 - 05:37 PM

Was This Post Helpful? 0
  • +
  • -

#14 mattmandery  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 17-May 13

Re: Form Submission Problem

Posted 17 May 2013 - 05:56 PM

Ok I went to http://localhost/ and checked the status and it said PHP active I also moved my whole folder into the directory you suggested (c/....htdocs) and I am still getting the same error. Also it is worth noting that When I installed XAMPP it said there was a problem installing mysql most likely because I have already installed mysql. Not sure if im still not getting something here....
Was This Post Helpful? 0
  • +
  • -

#15 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 405
  • View blog
  • Posts: 1,722
  • Joined: 30-April 10

Re: Form Submission Problem

Posted 17 May 2013 - 06:14 PM

Did you go to http://localhost/YOURDIR where YOURDIR is the name of the directory you added to the htdocs folder?
Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2