I'm trying to make a basic registration form on WAMP, I've tried with tutorials and a book.
I seem to be having a problem after I submit the data on the webpage.
I have created the database and tables and can be seen here... http://oi57.tinypic.com/2j47hux.jpg
Here is the code I have on my html page:
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#536977">
<tr>
<form method="post" action="register.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#536977">
<tr>
<td colspan="3"><strong>Register: </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input type="text" id="username"></td>
</tr>
<tr>
<td width="78">First Name</td>
<td width="6">:</td>
<td width="294"><input type="text" id="firstname"></td>
</tr>
<tr>
<td width="78">Last Name</td>
<td width="6">:</td>
<td width="294"><input type="text" id="lastname"></td>
</tr>
<tr>
<td width="78">Age</td>
<td width="6">:</td>
<td width="294"><input type="text" id="age"></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input type="text" id="email"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input type="text" id="password"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" value="Login"></td>
</tr>
</table>
</td
</form>
</tr>
</table>
The php I'm linking to is..
<?php
$con = mysqli_connect("localhost","root","","membersapp");
if (!$con)
{
die('Could not connect: ' . mysqli_error($con));
}
$sql="INSERT INTO memberstable (username, firstname, lastname, age, email, password)
VALUES
('$_POST[username]','$_POST[firstname]','$_POST[lastname]','$_POST[age]','$_POST[email]','$_POST[password]' )";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "$_POST[firstname] $_POST[lastname] has been added";
mysqli_close($con);
?>
I have ran a small php script to see if php connecting to database and it's connected.
Any ideas what is wrong?
Ok code edited..
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$con = mysqli_connect("localhost","root","","membersapp");
if (!$con)
{
die('Could not connect: ' . mysqli_error($con));
}
$sql="INSERT INTO memberstable (username, firstname, lastname, age, email, password)
VALUES
('$_POST[username]','$_POST[firstname]','$_POST[lastname]','$_POST[age]','$_POST[email]','$_POST[password]' )";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "$_POST[firstname] $_POST[lastname] has been added";
mysqli_close($con);
?>
and
<form method="post" action="register.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#536977">
<tr>
<td colspan="3"><strong>Register: </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input type="text" id="username" name="username"></td>
</tr>
<tr>
<td width="78">First Name</td>
<td width="6">:</td>
<td width="294"><input type="text" id="firstname" name="firstname"></td>
</tr>
<tr>
<td width="78">Last Name</td>
<td width="6">:</td>
<td width="294"><input type="text" id="lastname" name="lastname"></td>
</tr>
<tr>
<td width="78">Age</td>
<td width="6">:</td>
<td width="294"><input type="text" id="age" name="age"></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input type="text" id="email" name="email"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input type="password" id="password" name="password"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" value="Login"></td>
</tr>
</table>
</td>
</form>