Jump to content

Form submit problem.


Random

Recommended Posts

As you can tell from my recent outbreak of posting for newbie help, I am learning MySQL. I am now having trouble with a signup form and the process script. Here they are:

 

SIGNUP FORM:

 

[php:1:78927ec1bf]<?php

print \"<BR><BR><BR>\";

print \"<h1>Test for MySQL Tables</h1>\";

print \"<BR><BR><BR>\";

print \'<form action=\"signup_process.php\" method=\"post\">\';

print \'Desired Username: <input type=\"text\" name=\"username\" maxlength=20><BR>\';

print \'Desired Password: <input type=\"password\" name=\"password\" maxlength=20><BR>\';

print \'First Name: <input type=\"text\" name=\"f_name\" maxlength=25><BR>\';

print \'Last Name: <input type=\"text\" name=\"l_name\" maxlength=25><BR>\';

print \'Email Address: <input type=\"text\" name=\"email\" maxlength=\"60\"><BR>\';

print \'Age: <input type=\"text\" name=\"age\" maxlength=\"3\"><BR>\';

print \'Gender: Male<input type=\"radio\" name=\"male\" value=\"male\"> Female<input type=\"radio\" name=\"female\" value=\"female\"><BR>\';

print \'<input type=\"submit\" value=\"Finish signup!\">\';

?>[/php:1:78927ec1bf]

 

and the PROCESS SCRIPT:

 

[php:1:78927ec1bf]<?php

$dbuser = \"random\";

$dbpass = \"random\";

$dbname = \"random\";

$_POST[\'username\'] = $uname;

$_POST[\'password\'] = $pword;

$_POST[\'f_name\'] = $fname;

$_POST[\'$l_name\'] = $lname;

$_POST[\'email\'] = $email;

$_POST[\'age\'] = $age;

$_POST[\'gender\'] = $gender;

 

if (empty($_POST[\'username\']) || ($_POST[\'password\']) || ($_POST[\'f_name\']) || ($_POST[\'l_name\']) || ($_POST[\'email\']) || ($_POST[\'age\']) || ($_POST[\'gender\'])) {

print \"Please fill in all of the required fields!\";

 

}else {

 

$link = mysql_connect(\"localhost\", $dbuser, $dbpass) or die (\"Database Error: Couldn\'t Connect!\");

 

mysql_select_db($dbname, $link) or die (\"Couldn\'t open $db!\");

 

$query = \"INSERT INTO user_info (username, password, f_name, l_name, email, age, gender)

values( \'$uname\', \'$pword\', \'$fname\', \'$lname\', \'$email\', \'$age\', \'$gender\' )\";

 

mysql_query($query, $link) or die (\"Couldn\'t input data!\");

 

 

mysql_close($link);

}

 

 

?>[/php:1:78927ec1bf]

 

After I hit the submit button and process the form, no errors come up, so I goto my PuTTY box and get onto my database, select the columns, and they just added blank lines to it, no information what-so-ever. Help please.

Link to comment
Share on other sites

hmm your code looks fine, do a couple of echos to make sure you are getting the information from the form.

 

 

$_POST[\'$l_name\'] = $lname;

 

 

I\'m guessing here that the $ is a mistake but even so it shouldn\'t effect the rest of your variables.

Link to comment
Share on other sites

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.