Question:
What is the php equivalent of this jsp function??
sandydessert
2008-05-20 05:29:40 UTC
SendRedirect("page.jsp");

Also plz tell me what php script to write for the following:-

There should be options to enter a username and password (i know how to do this i.e. by using form ) and to click on a login button (just like how we enter into yahoo mail). Now, after clicking the login button it has to be checked whether the username and password entered are valid or not (they are stored in a MySQL table) and if valid then control should navigate to a new page say list.php
Five answers:
Rangacharyulu G
2008-05-22 22:28:37 UTC
$conn=mysql_connect('host','user','passw...

mysql_select_db('database',$conn);



$sql1="select user_id from users where user_id='".$_POST['uid']."' and password=PASSWORD('".$_POST['pwd']."')";



$rs=mysql_query($sql1,$conn) or die("Can not execute: ".mysql_error($conn));



if(mysql_num_rows($rs)==0)

{

$msg="Invalid User ID / Password";

header("Location:login.php");

}



else

{

session_start();

$row=mysql_fetch_array($rs);

$_SESSION['uid']=$_POST['uid'];

header("Location:page.php");

}
anonymous
2008-05-20 05:39:43 UTC
1) Header location.



2) Select the username and password from the database. If there's a record, it's valid. If there's no record with that username and password, it's not a valid login. The rest is html. (You might want to make use of PHP's MD5 function, storing passwords as MD5 hashes, and selecting for the username and the MD5 hash of the password the user enters.)
anonymous
2016-12-30 09:59:09 UTC
i think of Hypertext Preprocessor is less complicated to hack, yet its similiar to coding languages like java and C. in my opinion i do unlike asp in any respect because of the syntax, whether it rather relies upon on own determination and what your doing with it. If a threat, use jython/python with different markup languages.
PHPMine.com
2008-05-21 20:25:19 UTC
if(password_is_good($username, $password))

header("Location: member_page.php");

else

header("Location: login.php");



function password_is_good($username, $password){

$sql = "select count(*) from members

where username = '$username' and

password = '$password' limit 1";

$is_good = (bool) mysql_query($sql);

return $is_good;

}





if you need further assist just email me.
mhnd_79
2008-05-20 05:36:16 UTC
use the 'header' function


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...