Hi, i just managed to make a form that really post the info, the only problem is , when i check mysql database the fields are blank this is my code
<?php
function Connect_to_db($filename)
{
include($filename);
$connection = mysqli_connect($host, $user,$passwd)
or die ("Couldn't connect to server.");
$db = mysqli_select_db($connection,$database)
or die ("Couldn't select database.");
return $connection;
}
?>
<?php
$page = array( "title" => "Customer Login Page",
"top" => "",
"bottom" => "Send questions and comments
to admin@ourplace.com",
);
$elements_1 = array( "top" => "Returning Customers:
<span style=\"font-size: 80%;
font-weight: 100%\">
<i>Login here</i></span>",
"bottom" => "",
"submit" => "Login"
);
$elements_2 = array("top" => "New Customers:
<span style=\"font-size: 80%;
font-weight: 100%\">
<i>Register here</i></span>",
"bottom" => "",
"submit" => "Register"
);
$fields_1 = array("fusername" => "User Name",
"fpassword" => "Password"
);
$length_1 = array("fusername" => "10",
"fpassword" => "10"
);
$fields_2 = array("codigo" => "Codigo",
"producto" => "Producto",
"descripcion" => "Descipcion",
"precio" => "precio",
"imagen" => "imagen",
"fecha" => "fecha"
);
$length_2 = array("codigo" => "6",
"producto" => "50",
"descripcion" => "100",
"precio" => "12",
"imagen" => "40",
"fecha" => "16"
);
?>
<head><title><?php echo $page['title']?></title></head>
<body style="margin: 0">
<h1 align="center"><?php echo $page['top'] ?></h1>
<hr size="10" noshade>
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<td width="33%" valign="top">
<p style="font-size: 110%; font-weight: bold">
<?php echo $elements_1['top']?></p>
<!-- Beginning of form 1 (left) -->
<form action=<?php echo $_SERVER['PHP_SELF']?>
method="POST">
<table border="0">
<?php #26
if (isset($GLOBALS['message_1'])) #27
{
echo "<tr>
<td colspan='2'
style=\"font-weight: bold;
font-style: italic;
font-size: 90%; color: red\">
{$GLOBALS['message_1']}<p></td></tr>\n";
}
echo "<tr><td style=\"text-align: right;
font-weight: bold\">codigo</td>
<td><input type='codigo'
if(ereg("pass",$field)) #38
$type = "password";
else
$type = "text";
echo "<tr><td style=\"text-align: right;
font-weight: bold\">$value</td>
<td><input type='$type' name='$field'
value='".@$$field."'
size='{$length_1[$field]}'
maxsize='{$length_1[$field]}'>
</td></tr>\n";
#49
?>
<tr>
<td colspan="2" style="text-align: center" >
<br />
<input type="submit" name="Button"
value="<?php echo $elements_1['submit']?>">
</td></tr>
</table>
</form>
</td>
<!-- Column that separates the two forms -->
<td style="background-color: gray"></td>
<td width="67%">
<p style="font-size: 110%; font-weight: bold">
<?php echo $elements_2['top']?>
<!-- Beginning of Form 1 (right side) -->
<form action=<?php echo $_SERVER['PHP_SELF']?>
method="POST">
<p>
<table border="0" width="100%">
<?php #76
if (isset($GLOBALS['message_2'])) #77
{
echo "<tr>
<td colspan='2'
style=\"font-weight: bold; font-style: italic;
font-size: 90%; color: red\">
{$GLOBALS['message_2']}<p></td></tr>";
} #84
foreach($fields_2 as $field => $value) #85
{
if(ereg("pass",$field))
$type = "password";
else
$type = "text"; #110
echo "<tr><td style=\"text-align: right;
font-weight: bold\">$value</td>
<td><input type='$type' name='$field'
value=\"".@$$field."\"
size='{$length_2[$field]}'
maxsize='{$length_2[$field]}'>
</td></tr>"; #117
#118
} #119
?>
<tr><td colspan="2" style="text-align: center">
<p style="margin-top: .05in">
<input type="submit" name="Button"
value="<?php echo $elements_2['submit']?>">
</td></tr>
</table>
</form>
</td>
</tr>
</table>
<hr size="10" noshade>
<div style="text-align: center; font-size: 75%">
<?php echo $page['bottom']?>
</body></html>
<?php
session_start(); #9
$table_name = "catalog"; #11
$next_program = "SecretPage.php";
switch (@$POST['Button']) #14
{
case "Login": #16
$cxn = Connect_to_db("form.inc");
$sql = "SELECT user_name FROM $table_name
WHERE user_name='$POST[fusername]'"; #19
$result = mysqli_query($cxn,$sql)
or die("Couldn't execute query 1"); #21
$num = mysqli_num_rows($result);
if($num == 1) #23
{
$sql = "SELECT user_name FROM $table_name
WHERE user_name='$POST[fusername]'
AND password=md5('$POST[fpassword]')";
$result2 = mysqli_query($cxn,$sql)
or die("Couldn't execute query 2.");
$row = mysqli_fetch_assoc($result2); #30
if($row) #31
{
$SESSION['auth']="yes"; #33
$SESSION['logname'] = $POST['fusername']; #34
header("Location: $next_program"); #35
}
else #37
{
$message_1="The Login Name, '$POST[fusername]'
exists, but you have not entered the
correct password! Please try again.<br>";
extract($_POST);
} #45
} #46
elseif ($num == 0) // login name not found #47
{
$message_1 = "The User Name you entered does not
exist! Please try again.<br>";
}
break; #54
case "Register": #55
#79
#139
/* check to see if user name already exists */
$cxn = Connect_to_db("form.inc");
$today = date("Y-m-d"); #180
$sql = "INSERT INTO `catalog` (`codigo`, `producto`, `descripcion`, `precio`, `imagen`, `fecha`) VALUES ('$codigo', '$producto', '$descripcion', '$precio', '$imagen', '$fecha')";
mysqli_query($cxn,$sql) or die(mysqli_error($cxn)); #165
$_SESSION['auth']="yes"; #192
$_SESSION['logname'] = $user_name; #193
/* send email to new Customer */
$emess = "You have successfully registered. ";
$emess .= "Your new user name and password are: ";
$emess .= "\n\n\t$user_name\n\t";
$emess .= "password\n\n";
$emess .= "We appreciate your interest. \n\n";
$emess .= "If you have any questions or problems,";
$emess .= " email [email]service@ourstore.com[/email]"; #201
$subj = "Your new customer registration"; #202
#$mailsend=mail("$email","$subj","$emess"); #203
header("Location: $next_program"); #204
break; #206
default: #208
}
?>
Thanks for your help