Page 1 of 1

[SOLVED] litlle help need..

Posted: Tue Jul 27, 2004 9:32 pm
by g3ckO
This is the form: addform.php

Code: Select all

<?php
function user_form() 
{
?>
<b>Username:</td><td><input type="text" name="username"></td></tr>
    
<b>Password:</td><td><input type="text" name="password"></td></tr>

<form action="add_user_func.php" method="POST">
<input type="submit" value="SAVE" name="submit"></form>

<?     
}
user_form();
?>
add_user_func.php:

Code: Select all

<?php

require_once 'addform.php';
include("database.php");
include("login.php");

define('HOST', 'localhost');
define('USER', 'root');
define('PASS', '');
define('DB', 'db1');

if ($REQUEST_METHOD=="POST")
{
    if (!$_POST['username'] || !$_POST['password'])
	{
	echo("YOU DIDN'T FILL IN ALL THE REQUIRED FIELDS.");
	
	}

   	$username = $_POST['username'];
	$md5pass = md5($_POST['password']);

 global $conn;
   $q = "INSERT INTO employee VALUES ('$username', '$md5pass')";
   return mysql_query($q,$conn);

	$result = mysql_query($q, $conn);
	if (!$result)
		{
		echo("ERROR: " . mysql_error() . "\n$q\n"); 
		}
		echo("DATA SUCCESSFULY ADDED\n");
}
?>
Here is the problem:
I have fill in all the field in the form but why it still show the message ("YOU DIDN'T FILL IN ALL THE REQUIRED FIELDS.")

Posted: Tue Jul 27, 2004 9:58 pm
by litebearer
Try changing this line

Code: Select all

if (!$_POST&#1111;'username'] || !$_POST&#1111;'password'])
to this

Code: Select all

if (!isset($_POST&#1111;'username']) || !isset($_POST&#1111;'password']))

Posted: Tue Jul 27, 2004 10:01 pm
by g3ckO
Still doesn't work..

Posted: Tue Jul 27, 2004 10:01 pm
by kettle_drum
Also look at your tag order in your form. <form> should suround the form items as they are part of the form:

Code: Select all

<form action="add_user_func.php" method="POST"> 
   <b>Username:</td><td><input type="text" name="username"></td></tr>     
   <b>Password:</td><td><input type="text" name="password"></td></tr> 
   <input type="submit" value="SAVE" name="submit">
</form>

Posted: Tue Jul 27, 2004 10:13 pm
by g3ckO
So the form is wrong... :wink:

Tq guys... problem solved..