Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with a form

Status
Not open for further replies.

Fadius

IS-IT--Management
Jul 25, 2001
139
US
I am a ultra noob and could really use soem help. WHat I am trying to do is simple. I have an SQL table named: "tsign_demo"

This table has the following fields:

fname
lname
nick
email
squad

I want to have a form that when a user inputs the fields, it populates the table and validates that there is a fname, lname, and email.

Then, I want another form that will display fname, lname, squad, and nick

I am able to modify existing php documents, but creating a new one I am unabel to do with my current skills.

Any help would be greatly appreciated.
 
I'm pretty sure this is what you're asking for:

after the form is submitted, this script is run (a piece anyway)

Code:
<?
$goback=false;
if (isset($_REQUEST['fname'])) {
     $fname=$_REQUEST['fname'];
} else {
     $goback=true;
     $_SESSION['fname']=-1;
}
[i]do the same for each field[/i]
.
.
.
if ($goback) header("Location: userform.php");
//if not, keep going
.
.
//input into MySQL (obviously, you would change the function to mssql() if using SQL or whatever)

mysql_connect(.....);
mysql_select_db(.....);
$result=doQuery("INPUT INTO tablename (fname,lname,etc...) VALUES ('$fname','$lname','$etc....')");
?>

And in your form...
Code:
<? if ($_SESSION['fname']==-1) { ?>
<input name="fname" type.....><br>
<? }
   if ($_SESSION['lname']==-1) { ..... etc.

This is the simple version. You could also use session variables to save the user from reentering everything if they were kicked back: <input name="fname" type="input" value="<?= $_SESSION['fname']; ?>"> (if !=-1 anyway)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top