Page 1 of 1

Form Submit Not Storing Values

Posted: Tue Oct 26, 2010 2:59 pm
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.

Re: FORM SUBMIT NOT STORING VALUES

Posted: Tue Oct 26, 2010 3:04 pm
by twinedev
1. next time use the PHP Code button at the top of the editor ;-)

2. You need $_POST, not $_SESSION.

-Greg

Re: Form Submit Not Storing Values

Posted: Tue Oct 26, 2010 3:32 pm
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