Form Submit Not Storing Values

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
webbiz
Forum Newbie
Posts: 22
Joined: Sat Mar 20, 2010 12:04 am

Form Submit Not Storing Values

Post by webbiz »

My heads about to crack on this one.

I have a simple form.

=========================

Code: Select all

<body>
<form action="cc_billing.php" method="post">
  <label>Name
  <input type="text" name="name" id="name" />
  </label>

  <p>
    <label>Address1
    <input type="text" name="address1" id="address1" />
    </label>
  </p>
  <p>
    <label>Address2
    <input type="text" name="address2" id="address2" />
    </label>
  </p>
  <p>
    <label>City
    <input type="text" name="city" id="city" />
    </label>
  </p>
  <p>
    <label>State
    <input type="text" name="state" id="state" />
    </label>
  </p>
  <p>
    <label>Country
    <input type="text" name="country" id="country" />
    </label>
  </p>
  <p>
    <label>Zip Code
    <input type="text" name="postalcode" id="postalcode" />
    </label>
  </p>
  <p>
    <label>Submit
    <input type="submit" name="submit" id="submit" value="Submit" />
    </label>
  </p>
</form>
</body>

=======================================

And when you click on Submit, all I want to do is to display the Session variables.

cc_billing.php

============================

Code: Select all

<?php 

session_start();

$name = $_SESSION['name'];
$address1 = $_SESSION['address1'];	
$address2 = $_SESSION['address2'];
$city = $_SESSION['city'];
$state = $_SESSION['state'];
$postalcode = $_SESSION['postalcode'];
$phone = $_SESSION['phone'];
$email = $_SESSION['email'];
$country = $_SESSION['country'];

echo "<hr />";
echo "CUSTOMER INFORMATION PROVIDED<br /><br />";
echo "<strong>$name</strong> <br />";
echo "<strong>$address1</strong> <br />";

if (empty($address2) == FALSE) 
	echo "<strong>$address2</strong> <br />";
echo "<strong>$city, $state</strong> <br />";
echo "<strong>$country</strong><br />";
echo "<strong>$postalcode</strong> <br /><br />";
echo "<strong>$phone</strong> <br />";
echo "<strong>$email</strong> <br />";

echo "<hr />";

?>
========================

The only thing that shows up is "CUSTOMER INFORMATION PROVIDED" and the "," between where City and State should be.

The variables are not storing the values from the form.

It worked yesterday when I first started on this project. I had to keep working on it because I was going back to the form and trying to make it persistent.

But today, it simply won't store a darn thing!

Any ideas?

Thanks.
Last edited by Benjamin on Tue Oct 26, 2010 3:07 pm, edited 1 time in total.
Reason: Removed ALL CAPITAL title. Added [syntax=php] tags.
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: FORM SUBMIT NOT STORING VALUES

Post by twinedev »

1. next time use the PHP Code button at the top of the editor ;-)

2. You need $_POST, not $_SESSION.

-Greg
webbiz
Forum Newbie
Posts: 22
Joined: Sat Mar 20, 2010 12:04 am

Re: Form Submit Not Storing Values

Post by webbiz »

Thanks Greg!

Yep, that did the trick.

I'm a bit fuzzy as to the difference between the two methods of retrieval.

Thanks again.

Webbiz
Post Reply