Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
February 8, 2006, 5:00 pm
rate this thread
are in one page. I want PHP to control where the next page is. It
page doesn't do anything besides the validation. Thanks for your
$_SESSION['login'] = $_POST['login'];
$sql = "SELECT first_name, last_name, security_access, expire,
passwd_date FROM sy_user WHERE login = '".$_SESSION['login']."' AND
password = '".substr(sha1($_POST['password']), 0, 10)."'";
$result = mysql_query($sql);
if (mysql_num_rows($result) < 1)
$msg = "Invalid login and password!";
$row = mysql_fetch_assoc($result);
$_SESSION['first_name'] = $row['first_name'];
$_SESSION['last_name'] = $row['last_name'];
$_SESSION['security_access'] = $row['security_access'];
$passwd_date = $row['passwd_date'];
$expire = $row['expire'];
if ($passwd_date + $expire < date('Y-m-j'))
alert("Please fill "+form[f].name.substring(5));
Login:<input name="reqd.login" type="text"><br>
Password:<input name="reqd.password" type="password"><br>
<input type="submit" name="process" value="Login"
<?php echo($msg); ?>
button to the form's onsubmit() event:
<form method="post" onsubmit="return checkrequired(this);">
It'll work as you expect :) The problem at the moment is that your
"true" or "false", as a function being called by onsubmit() would be
expected to do, but it's being used in a different fashion. Try dropping it
in the <form> tag as I showed above and see if that makes a difference.
work. I'll try it again. However, what if I have multiple submit
clicked. What if I have a Quit button as well that calls a different
distinquish between two different functions when each button is
clicked. That's why I used the onclick event so I can assign a
But just so long as the form is submitted. Thanks.... Chong
What does the quit button do?
You can have each button assign a value to a hidden input in your form -
called, say, "action", then call the submit() method of the form
(document.getElementById("form_id").submit()). That will definitely be
picked up by any functions looking at the form after said value has been
validation, it needs to know where to send the form data. You have the method
set to "post" but were missing the action setting. If you are sending the form
back to itself you can usually specify that in PHP using...
<form action="<?php $PHP_SELF; ?>" method="post">
You might need to pull the "onClick" event from your submit button and include
that in the form tag as well.
Newsguy BonusBytes! - Free monthly rewards