|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Some help with login script
Hi guys, thanks for the help yesterday. Im trying to create a login script which will compare the input values with mysql and then redirect the user to a "welcome" page if it succeeds or else reject. ive created 3 cards but they dont seem to be working.
PHP Code:
login.wml
PHP Code:
login.php
PHP Code:
result.php
Last edited by jabba_29 : April 25th, 2006 at 08:04 AM. Reason: code tags again :) |
|
#2
|
||||
|
||||
|
Look at the code that I provided yesterday, especially the postfield part. Your first card doesn't have them, so it won't be passing any data to the second card.
Also, your syntax is awful. Sorry to be so blunt, but as I stated yesterday (though I should add that tags need to be in lowercase too): Quote:
__________________
Cheers, Jamie # skiFFie | Home of the 'accessibility module' for Drupal # Jamie Burns [me] Accessibility Module [drupal] # guidelines | search | wap resources | not getting help | fold to cure # Any form of employment is strictly prohibited ...... __________________ Let the might of your compassion arise to bring a quick end to the flowing stream of the blood and tears ..... Please hear my anguished words of truth. __________________ |
|
#3
|
|||
|
|||
|
Hi again jabba, i made some corrections to the from. not sure am i going in the right direction. Ive corrected as much as the syntax as i can
login.php Code:
<?php
header('Content-Type: text/vnd.wap.wml, true');
echo '<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">';
?>
<wml>
<card id="login1" title="login">
<p align="center">
<?php
// connect to mysql database
require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");
$connection = mysql_connect($db_host, $db_user, $db_password) or die("error connecting");
mysql_select_db($db_name, $connection);
?>
<p>
<p>User Login Form</p>
<form action="login1.php" method="POST">
<p><STRONG>Username:</STRONG><br>
<input type="text" name="username"></p>
<p><strong>Password:</strong><br>
<input type="text" name="password"></p>
<p><input type="submit" name="submit" value="go">
<do type="accept">
<go href="login1.php" method="post">
<postfield name="username" value="$(username)"/>
<postfield name="password" value="$(password)"/>
</go>
/do>
<a href="home.php">Back</a>
</p>
</card>
</wml>
login1.php Code:
<?php
header('Content-Type: text/vnd.wap.wml, true');
echo '<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">';
?>
<wml>
<card id="login2" title="login2">
</p>
<?php
//check for required fields from the form
if ((!$_POST[username]) || (!$_POST[password])) {
header("Location: login.php");
exit;
}
//connect to server and select database
require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");
$connection = mysql_connect($db_host, $db_user, $db_password) or die("error connecting");
mysql_select_db($db_name, $connection);
//create and issue the query
$sql = "select f_name, l_name from owner_details where username = '$_POST[username]' AND password('$_POST[password]')";
$result = mysql_query($sql,$connection) or die(mysql_error());
//get the number of rows in the result set; should be 1 if a match
if (mysql_num_rows($result) == 1) {
//if authorized, get the values of f_name l_name
$f_name = mysql_result($result, 0, 'f_name');
$l_name = mysql_result($result, 0, 'l_name');
//set authorization cookie
setcookie("auth", "1", 0, "/", "yourdomain.com", 0);
//create display string
$display_block = "<P>$f_name $l_name is authorized!</p>
<p>Authorized Users' Menu:
<ul>
<li><a href=\"resultpage.php\">secret page</a>
</ul>";
} else {
//redirect back to login form if not authorized
header("Location: login.php");
exit;
}
?>
<a href="home.php">Back</a>
</p>
</card>
</wml>
|
|
#4
|
||||
|
||||
|
I have commented the first card you posted again, see below. Please run your scripts through a validator, you can easily work out the correct syntax if you stop trying to do everything in such a hurry and actually read a couple of the tutorials.
PHP Code:
login.php
|
|
#5
|
|||
|
|||
|
Thanks for the help last week jabba, i got the scripts running fine. The login is grand now and displays what i want. Im having a little trouble with one final part of the site, ive created a php srcipt which enables a user to update pr add a premises when they login. For now i just want to feature an option which enables a new user, after they login 2 add a premises. Ive got to the stage where it diplays the fields in the form, how do i create a simple submit in the end which adds the premises into the database?
PHP Code:
Last edited by jabba_29 : May 1st, 2006 at 07:37 PM. |
|
#6
|
||||
|
||||
|
Yet again, you have no fieldset in your form - you are using HTML forms and HTML, not xml/wml. You are also confusing methods for your forms, your submit action. You have used "post" but you are checking against $_GET['submit'] which is never going to be set.
|
|
#7
|
||||
|