Free Web Hosting Forum
Go Back   Free Web Hosting Forum > Website Building > Web Programming
Reload this Page Why is my php script not picking up data from form?
Reply
 
Thread Tools Display Modes
(#1 (permalink))
Old
Junior Member
idhrahil is on a distinguished road
 
Posts: 7
Join Date: Jun 2012
Unhappy Why is my php script not picking up data from form? - 06-05-2012, 11:52 AM

I have created an html form, and am looking to create various php scripts to process the data. However, nothing seems to be working.

My form is something like this:

Quote:
<form name="Contact_Form" method="post" action="contactform.php" enctype="text/plain" id="Form1" onsubmit="return ValidateContact_Form(this)">
<div id="bv_Text4" style="margin:0;padding:0;position:absolute;left:3 0px;top:23px;width:179px;height:41px;text-align:left;z-index:0;">
<font style="font-size:43px;background-color:#FFFFFF" color="#000045" face="LilyUPC">Name:</font></div>
<input type="text" id="Editbox1" style="position:absolute;left:250px;top:21px;width :343px;height:43px;border:1px #C0C0C0 solid;color:#000045;font-family:LilyUPC;font-size:43px;z-index:1" name="name" value="">
<div id="bv_Text6" style="margin:0;padding:0;position:absolute;left:3 0px;top:73px;width:207px;height:41px;text-align:left;z-index:2;">
<font style="font-size:43px;background-color:#FFFFFF" color="#000045" face="LilyUPC">E-mail address:</font></div>
<input type="text" id="Editbox2" style="position:absolute;left:250px;top:71px;width :343px;height:43px;border:1px #C0C0C0 solid;color:#000045;font-family:LilyUPC;font-size:43px;z-index:3" name="email" value="">
<div id="bv_Text7" style="margin:0;padding:0;position:absolute;left:3 0px;top:123px;width:207px;height:41px;text-align:left;z-index:4;">
<font style="font-size:43px;background-color:#FFFFFF" color="#000045" face="LilyUPC">Message:</font></div>
<textarea name="message" id="TextArea1" style="position:absolute;left:30px;top:173px;width :563px;height:148px;border:1px #C0C0C0 solid;color:#000045;font-family:LilyUPC;font-size:43px;z-index:5" rows="2" cols="44"></textarea>
<input type="submit" id="Button1" name="Button1" value="Submit" style="position:absolute;left:30px;top:348px;width :75px;height:24px;font-family:Arial;font-size:13px;z-index:6">
</form>
When I run contactform.php, it doesn't pick up any of the values from the form. I have tried even the most basic manipulation - printing Hello "name", for instance - but the data never shows up. For instance, if I use:

Quote:
<html>
<body>
Welcome <?php print $_POST["email"]; ?>
</body>
</html>
all that is displayed is "Welcome ".

Am I doing something really stupid? I've played around with it for hours now. Or is it something to do with the server/hosting account that I don't know about?
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
dx4's Avatar
dx4 dx4 is offline
Member
dx4 is on a distinguished road
 
Posts: 95
Join Date: Mar 2012
Send a message via Skype™ to dx4
Default 06-05-2012, 01:03 PM

Remove the

enctype="text/plain"

from the form tag.

It should work after you remove this.


And when everything else fail, try reading the manual.

Last edited by dx4; 06-05-2012 at 01:54 PM.
Reply With Quote
(#3 (permalink))
Old
Junior Member
idhrahil is on a distinguished road
 
Posts: 7
Join Date: Jun 2012
Default 06-05-2012, 01:16 PM

Cheers, that works great. I thought I'd already tried that, but apparently not. What a waste of time! Thanks very much.
Reply With Quote
(#4 (permalink))
Old
Junior Member
idhrahil is on a distinguished road
 
Posts: 7
Join Date: Jun 2012
Default New but related problem - 07-17-2012, 11:20 AM

So, I have a very similar problem once again. I have a form which includes password entry boxes, which look something like this:

HTML Code:
<form name="Survey" method="post" action="formprocessor.php" id="Form1">
...
<div id="bv_Text22" style="margin:0;padding:0;position:absolute;left:9px;top:551px;width:998px;height:16px;text-align:left;z-index:36;">
<font style="font-size:13px" color="#000000" face="Arial"><b>6. What is your favourite colour?</b></font></div>
<input type="password" id="Editbox1" style="position:absolute;left:44px;top:574px;width:298px;height:20px;border:1px #C0C0C0 solid;font-family:'Courier New';font-size:16px;z-index:37" name="Question 6" value="">
...
</form>
I'm trying to e-mail the results using a php script, but the e-mail just gives me blank spaces instead of the values entered, and I can't work out why. The field names are unique.

PHP Code:
<?php

$data1 
$_POST["Question 6"];
$data2 $_POST["Question 8.1"];
$data3 $_POST["Question 8.2"];
$data4 $_POST["Question 8.3"];
$data5 $_POST["Question 8.4"];
$data6 $_POST["Question 8.5"];

$to "name@example.com";

$subject "subject";

$message "Data given was: " $data1 ", " $data2 ", " $data3 ", " $data4 ", " $data5 ", " $data6;
$message wordwrap($message70);

mail($to,$subject,$message);

header ("location: complete.php")

?>
Can anyone tell me what is going on? The result I get in the e-mail is:
Quote:
Data given was: , , , , ,

Last edited by d3iti; 07-17-2012 at 12:51 PM. Reason: I added php and html tags to the code.
Reply With Quote
(#5 (permalink))
Old
d3iti's Avatar
Super Moderator
d3iti is on a distinguished road
 
Posts: 6,537
Join Date: Jul 2009
Location: Spain
Default 07-17-2012, 12:49 PM

Hello,

You can try (test mode) to add this statement at the beginning:
PHP Code:
 print_r($_POST); 
It also checks if the id property of input is equal to the name property of input.


Recuerda realizar copias de seguridad de tus sitios web. Si este mensaje te ayudó puedes pulsar sobre el botón karma
Reply With Quote
(#6 (permalink))
Old
Junior Member
idhrahil is on a distinguished road
 
Posts: 7
Join Date: Jun 2012
Default 07-17-2012, 12:57 PM

Thanks for your help.

I've managed to work out what the problem was: it didn't like the space in the name, all solved by replacing it with an underscore.
Reply With Quote
Reply

Tags
form, php, post

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com