Jump to content

Recommended Posts

 

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.

 

-------------------------------------------------------------------

 

 

Link to comment
https://forums.phpfreaks.com/topic/178927-solved-form-processing-problem/
Share on other sites

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

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

 

 

 

 

 

 

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.

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

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.