I need help entering these forms into Mysql
Posted: Wed Oct 06, 2010 8:25 pm
I have two webpages, login_success.php and formentered.php
login_success.php is a page where i am entering new information and enteredvalues.php is supposed to be a script to enter the information into mysql. So far I got the login_success page to redirect to enteredvalues.php when submit is clicked but the information in the fields isn't transferring to mysql and neither is the page redirecting back to login_success. Here are both my codes
Login_success.php
Here is enteredvalues.php
login_success.php is a page where i am entering new information and enteredvalues.php is supposed to be a script to enter the information into mysql. So far I got the login_success page to redirect to enteredvalues.php when submit is clicked but the information in the fields isn't transferring to mysql and neither is the page redirecting back to login_success. Here are both my codes
Login_success.php
Code: Select all
<?
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>
<html><title>ChronoServe - Saving Time</title>
<link href="style.css" rel="stylesheet" type="text/css">
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="container">
<tr>
<td><form name="form2" method="post" action="entervalues.php">
<table width="335px" height="50%" border="1" align="center" cellpadding="0" cellspacing="0" class="centered">
<tr>
<td><table width="100%" border="0" align="center" cellpadding="3" cellspacing="10">
<tr>
<td colspan="2"><div align="center" class="font2">Activation Information</div></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td width="40%" class="font3">First Name :</td>
<td width="60%"> <div align="center">
<input name="firstname" type="text" class="font3" id="firstname" />
</div></td>
</tr>
<tr>
<td class="font3">Last Name :</td>
<td> <div align="center">
<input name="lastname" type="text" class="font3" id="lastname" />
</div></td>
</tr>
<tr>
<td height="28" class="font3">Phone Number :</td>
<td> <div align="center">
<input name="pnumber" type="text" class="font3" id="pnumber" />
</div></td>
</tr>
<tr>
<td class="font3">Personnel Activated :</td>
<td> <div align="center">
<input name="numbactivated" type="text" class="font3" id="numbactivated" />
</div></td>
</tr>
<tr>
<td height="37" colspan="2"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input name="insert" type="submit" class="font3" value="Submit" />
</div></td>
</tr>
</table></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</body>
</html>
Code: Select all
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="pin39056"; // Mysql password
$db_name="chronoserve"; // Database name
$tbl_name="disney_database"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Define $myusername and $mypassword
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$pnumber=$_POST['pnumber'];
$numberactivated=$_POST['numberactivated'];
// To protect MySQL injection (more detail about MySQL injection)
$firstname = stripslashes($firstname);
$lastname = stripslashes($firstname);
$firstname = mysql_real_escape_string($firstname);
$lastname = mysql_real_escape_string($lastname);
$pnumber = stripslashes($pnumber);
$numberactivated = stripslashes($numberactivated);
$pnumber = mysql_real_escape_string($pnumber);
$numberactivated = mysql_real_escape_string($numberactivated);
$sql="INSERT INTO $tbl_name (firstname, lastname, pnumber, numberactivated,) VALUES ('$firstname','$lastname','$pnumber','$numberactivated')")or die(mysql_error());
$r = mysql_query($sql);
if(!$r) {
$err=mysql_error();
print $err;
header("location:login_success.php");
exit();
}
?>