School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
You're Browsing As A Guest! Register Now...
Become an Expert!

Join 357,624 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,570 people online right now.Registration is fast and FREE... Join Now!



Clearing Form Variables

52 Weeks of Code Challenge: Android

Week #11 of the 52 Weeks of Code Challenge is Android, you should give it a shot. Click Here!

Clearing Form Variables *rips hair our* Rate Topic: -----

#1 snoj  Icon User is offline

  • Married Life
  • Icon

Reputation: 42
  • View blog
  • Posts: 3,475
  • Joined: 31-March 03


Dream Kudos: 775

Posted 20 November 2003 - 08:06 PM

For a challenge and maybe a Christmas present for my dad, I decided to make a php script that can handle his bill storage, making, and searching needs. Well I'm new to php and newer to forms. Anyway so far my script queries the DB for current client entries (so far just returns "test") and places a form at the bottom to enter new clients. Anyway when I reload the page the same $name and $address variables are loaded into the DB! As you can see from my script I've tried sessions and unset(), but non have worked. So either I'm doing it wrong or I'm not even on the right track.

Any help will be very appreciated. :D

<?php
session_id();
session_start();
include("mysql.php");

$db1a=mysql_query("SELECT * FROM categories WHERE parent_id = 0");
while($db1=mysql_fetch_array($db1a))
	{
  echo "test<br>";
	}
echo("<hr width=\"50%\" align=\"left\">");
echo("<b>Enter new client</b><br>
<form action=\"{$PHP_SELF}\" method=\"POST\">
<input type=hidden name=\"redirect\" 
value=\"index.php\">
Name: <input type=\"text\" name=\"name\" size=\"30\" maxlength=\"256\"><br>
Address: <input type=\"text\" name=\"address\" size=\"30\" maxlength=\"256\"><br>
<input type=\"submit\" name=\"submit\" value=\"Enter information\">
</form>");

if($submit)
	{
  if($name == "")
 	 {
    echo("Sorry you have to enter a name!");
 	 }
  if($address == "")
 	 {
    echo("Sorry you have to enter an address!");
 	 }
//  $sql=mysql_query("INSERT INTO categories (name, address) VALUES ('{$name}','{$address}')");
//  unset($name, $address);

	}
session_unset();
session_destroy();
?>


Was This Post Helpful? 0
  • +
  • -


#2 snoj  Icon User is offline

  • Married Life
  • Icon

Reputation: 42
  • View blog
  • Posts: 3,475
  • Joined: 31-March 03


Dream Kudos: 775

Re: Clearing Form Variables

Posted 21 November 2003 - 03:42 AM

Fixed. Just used header("Location: redirect.html");
Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month