PHP Classes

simple form fails to send data

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  simple form fails to send data  
Subject:simple form fails to send data
Summary:I have a form for registering admin users, but it has failed
Messages:6
Author:Davis J. Weddi
Date:2010-04-05 11:43:08
Update:2010-04-19 12:56:47
 

  1. simple form fails to send data   Reply   Report abuse  
Picture of Davis J. Weddi Davis J. Weddi - 2010-04-05 14:55:23
some one help look into these scripts and let me know where I have gone wrong:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//this is the form file name add_user.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add admin User</title>
</head>

<body>
<table align="center" width="305"><tr><td>
<fieldset><center><H2>Adding a Record to authorised users</H2></center>
<table width="300" height="235" align="center" bgcolor="#FAFAFA">
<FORM METHOD="POST" ACTION="do_adduser.php">
<tr height="23" width="150">
<td height="20" width="120"><P><STRONG>First Name:</STRONG><BR>
<INPUT TYPE="text" NAME="f_name" SIZE=25 MAXLENGTH=50></p></td></tr>
<tr height="23" width="150">
<td height="20" width="120"><P><STRONG>Last Name:</STRONG><BR>
<INPUT TYPE="text" NAME="l_name" SIZE=25 MAXLENGTH=50></p></td></tr>
<tr height="23" width="150">
<td height="20" width="120"><P><STRONG>Username:</STRONG><BR>
<INPUT TYPE="text" NAME="username" SIZE=25 MAXLENGTH=25></p></td></tr>
<tr height="23" width="150">
<td height="20" width="120"><P><STRONG>Password:</STRONG><BR>
<INPUT TYPE="text" NAME="password" SIZE=25 MAXLENGTH=25></p></td></tr>
<tr height="23" width="150">
<td height="20" width="120"><P>
<input type="SUBMIT" name="submit" value="Add User" />
</P></td></tr>
</FORM></table>
</fieldset>
</td></tr></table>
</body>
</html>
// end of the form

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// this is the action script - saved as do_adduser.php
<?php
//check for required fields
if ((!$_POST[f_name]) || (!$_POST[l_name]) || (!$_POST[username]) || (!$_POST[password])) {
header( "Location: http://localhost/simpledata/add_story_form.php");
exit;
}


$db_name = "simpledata";
$table_name = "auth_users";


$connection = @mysql_connect("localhost", "root", "") or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());

$sql = "INSERT INTO $table_name (f_name, l_name, username, password) VALUES ('$_POST[f_name]', '$_POST[l_name]', '$_POST[username]', '$_POST[password]')";

$result = @mysql_query($sql, $connection) or die(mysql_error());

?>

<HTML>
<HEAD>
<TITLE>Add admin User</TITLE>
</HEAD>
<BODY>
<table align="center" width="300" border="1" bordercolor="#ABABAB" cellpadding="2"><tr><td>
<H2>Added to admin users:</H2>
<P><STRONG>First Name:</STRONG><BR>
<? echo "$_POST[f_name]"; ?></p>
<P><STRONG>Last Name:</STRONG><BR>
<? echo "$_POST[l_name]"; ?></p>
<P><STRONG>Username:</STRONG><BR>
<? echo "$_POST[username]"; ?></p>
<P><STRONG>Password:</STRONG><BR>
<? echo "$_POST[password]"; ?></p>

<P><a href="show_adduser.html">Add Another</a></p></td></tr></table>

</BODY>
</HTML>
// end of action script

There are 5 replies in this thread, which are not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.