PHP linking issue from html page to php page?
-
Hi Guys ok i have created this form on a html page in dreamweaver - <form action="login.php" method="post" name="Customer Login" id="Customer Login" style="left: 683px; top: 671px;" > <label for="textfield" class="p">Username</label> <input name="textfield" type="text" id="textfield" size="20" maxlength="20" autofocus/> <label for="textfield2" class="p"> Password</label> <input name="textfield2" type="password" id="textfield2" size="20" maxlength="20" /> <input type="submit" name="button" id="button" value="Login" /> </form> I thought ihave linked it to the login.php page i created - <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_strin... ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['textfield'])) { $loginUsername=$_POST['textfield']; $password=$_POST['textfield2']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "Home.php"; $MM_redirectLoginFailed = "noaccess.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_dansiDB, $dansiDB); $LoginRS__query=sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $dansiDB) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();} //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> but my issue is that this will only work if i put the php into the html page which i dont want to do becuase i think it is messy and dont want to do this on each html page i create for login and want to be able to point any html page to the login.php page. the error i am getting it i cant create a 'log in' behaviour under server behaviours within dreamweaver and it says i must have a form on this page to use this behaviour. help! cheers
-
Answer:
Create a login.php which presents the form, on submission validates it and sets session cookies, then d=redirects to calling page. On the calling page, if login is needed, check first thing for the session cookies and if not present, redirect to login.php.
simon at Yahoo! Answers Visit the source
Other answers
Create a login.php which presents the form, on submission validates it and sets session cookies, then d=redirects to calling page. On the calling page, if login is needed, check first thing for the session cookies and if not present, redirect to login.php.
Sadsongs
Related Q & A:
- How to dispaly HTML page in Silverlight application?Best solution by devproconnections.com
- How can we reload html page without blinking?Best solution by Stack Overflow
- How can I make a dynamic web page in PHP?Best solution by Yahoo! Answers
- How can I make a page my home page?Best solution by Yahoo! Answers
- Why are HTML and PHP forms not working?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.