jdar Posted October 25, 2009 Share Posted October 25, 2009 Hi, I'm pretty new to php and I'm stuck on a basic form processing example. Below is the code that I've adapted from an example on php.net (for brevity I've omitted the html tags) The problem I'm having is that when I fill out the text fields and hit submit, the "additionsuccessful.php" is displayed with only the first field completed. I've been trying to figure this out for about 5 hours now to no avail. I'd appreciate if anyone could give me any pointers as to where I'm going wrong. Thanks in advance. john ---------------------------------------------------------------- <form action="additionsuccessful.php" method = "post"> Customer Name: <input type="text" name="name" /><br /> Carrier: <input type="text" name="carrier" /><br /> Service ID: <input type="text" name="service" /><br /> Termination Points: <input type="text" name="termpoints" /><br /> Service Type: <input type="text" name="servtype" /><br /> <input type="submit" /></p> -------------------------------------------------------------------- You have successfully added: <br> <br> Customer Name: <?php echo $_POST["name"];?> <br /> Carrier: <?php echo $_POST["carrier"];?> <br /> Service ID: <?php echo $_POST["service"];?> <br /> Termination Points : <?php echo $_POST["termpoints"];?> <br /> Service Type: <?php echo $_POST["servtype"];?> <br /> <br> to the database. ------------------------------------------------------------------- Quote Link to comment https://forums.phpfreaks.com/topic/178927-solved-form-processing-problem/ Share on other sites More sharing options...
cbolson Posted October 25, 2009 Share Posted October 25, 2009 Hi, your brevity, whilst appreciated, makes it rather difficult to know what is going wrong. Can you post the complete code for additionsuccessful.php? You say: "... "additionsuccessful.php" is displayed with only the first field completed." What do you mean by this? completed where? Are you saving this to a database? Have you tried printing out the POST values to see what your additionsuccessful.php is actually receiving? Try adding print_r($_POST); at the beginning of the page to show what the page is getting. Chris Quote Link to comment https://forums.phpfreaks.com/topic/178927-solved-form-processing-problem/#findComment-943985 Share on other sites More sharing options...
jdar Posted October 25, 2009 Author Share Posted October 25, 2009 Hi, thanks for the reply Since my first post, the code seems to be doing what I want it to do now. About 5 hours of not working, then suddenly it does. I didn't add or change anything to facilitate this so I'm a little confused as I don't know why this should happen. This may be rather superflous now, but for the sake of completeness, this is a fuller description of the problem. Following this example http://www.php.net/manual/en/tutorial.forms.php I don't have any problems so I wanted to expand upon it. I'm using xampp which uses PHP 5.3.0 if that is any help. I'm not using a database as yet as I'm trying to get a grasp on the basics first. Including the html tags, the code looks like this. *filename addcustomer.html ------------------------------------------------------------------------- <html> <title>Add Customer</title> <br> <hr> <head><center><font size="10" color="black">Add Customer</font></center></head> <br> <hr> <br> <body> <form action="additionsuccessful.php" method = "post"> Customer Name: <input type="text" name="name" /><br /> Carrier: <input type="text" name="carrier" /><br /> Service ID: <input type="text" name="service" /><br /> Termination Points: <input type="text" name="termpoints" /><br /> Service Type: <input type="text" name="servtype" /><br /> <input type="submit" /></p> </form> </body> </html> ------------------------------------------------------------------------- filename additionsuccessful.php ------------------------------------------------------------------------ <html> <body> You have successfully added: <br> <br> Customer Name: <?php echo $_POST["name"];?> <br /> Carrier: <?php echo $_POST["carrier"];?> <br /> Service ID: <?php echo $_POST["service"];?> <br /> Termination Points : <?php echo $_POST["termpoints"];?> <br /> Service Type: <?php echo $_POST["servtype"];?> <br /> <br> to the database. </body> </html> ------------------------------------------------------------------------- addcustomer.html returns a page exactly as I planned with title, heading and text boxes for the relevant fields. EG: -------------------- Customer Name: Carrier: Service ID: Termination Points: Service Type: ---------------------- Filling in these fields with, for example, the following info: ---------------------- Customer Name: AB Carrier: CD Service ID:EF Termination Points: GH Service Type: IJ ---------------------- Returns the following info in the additionsuccessful.php file. ----------------------------- You have successfully added: Customer Name: AB Carrier: Service ID: Termination Points : Service Type: to the database. ----------------------------- As a mentioned, this problem seems to be solved, but I don't know how or why! Any ideas or should I just draw a line under this? Apologies for the perhaps long-winded and superflous post. Thanks, john Quote Link to comment https://forums.phpfreaks.com/topic/178927-solved-form-processing-problem/#findComment-944012 Share on other sites More sharing options...
PFMaBiSmAd Posted October 25, 2009 Share Posted October 25, 2009 Since my first post, the code seems to be doing what I want it to do now. Where and how are you testing this code? Live servers often have file/page caching and headers setup that can prevent changes made to content from immediately showing up, unless you specifically output your own headers to prevent any caching on the server or in the browser or in any device in between them. Quote Link to comment https://forums.phpfreaks.com/topic/178927-solved-form-processing-problem/#findComment-944034 Share on other sites More sharing options...
jdar Posted October 26, 2009 Author Share Posted October 26, 2009 Hi, thanks for your response. I'm testing this code on local host. Changes made to the html appear straight away so I'm guess that caching isn't an issue here. Not too sure what was happening, but the code is still working as I expect so I'll mark this thread as solved. Thanks for your time. john Quote Link to comment https://forums.phpfreaks.com/topic/178927-solved-form-processing-problem/#findComment-944635 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.