You are here: Re: Can you _POST variables in php without using a <FORM> « All PHP « IT news, forums, messages
Re: Can you _POST variables in php without using a <FORM>

Posted by Markus Ernst on 01/21/06 15:20

chris_fieldhouse@hotmail.com schrieb:
> Hi fairly new to php, but picking it up quite well.
> the question I have, is it possible for a php script which is used to
> validate values submitted in a form, to then post these values onto
> another script/page or even back to the calling form?
>
> i.e. the application I have in question is a login.htm page with a
> verify.php script
> The login.htm has a Form which captures login_id and password which are
> posted to verify.php
>
> verify.php checks the id and password against the database.
> if the check succeeds I use $_SESSION to track the logged in user into
> the page.
> if the check fails, I use $_SESSION["error"] to set an error message
> and then jump to login.htm, but I've lost the userid.

http://www.alt-php-faq.org/local/55/#id55

Anyway cou can do it easier - don't post to verify.php, but implement
the verify mechanism in login.php:

<?php
if (isset($_POST['user'])) {
$user = $_POST['user'];
$password = $_POST['password'];
$check = your_login_check_function($user, $password);
if ($check) {
$_SESSION['logged'] = $_POST['user'];
header("Location: your_welcome_page.php");
exit;
}
else {
$msg = "Login incorrect, try again!";
}
}
else {
$user = "";
$password = "";
$msg = "Please log in!";
}
?>
<html>
<head>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<h1><?php echo $msg; ?></h1>
<p>Username: <input type="text" value="<?php echo $user; ?>"
name="user"></p>
<p>Password: <input type="text" value="<?php echo $password; ?>"
name="password"></p>
<p><input type="submit" value="Send" name="send"></p>
</form>
</body>
</html>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация