Jump to content

Recommended Posts

Basically this is what i would like to do i will also post the code ive made. With a php program i would like to connect to my database, collect data from a form and save it into variables and create a query to search the user table to see if the user can basically login or not.  I have create my Form, php program and database. Below is the copy of my php code:

<?
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("memberdir") or die(mysql_error());
?>

<?
$appusername=$_POST['login_name'];
$apppassword=$_POST['password'];

$result = mysql_query(" SELECT * FROM 'user' WHERE username = $appusername AND password = $apppassword ")

if (mysql_num_rows($result) > 0) {

$_SESSION["authenticatedUser"] = $appusername;

header("Location: loggedon.php");

}

else

{

$_SESSION["message"] = "Could not connect as  $appusername ";

header("Location: login.php");

}

?>

i really wish you can help. BAsically when i submit my 'login' form i get a parse error at line 12
That's not the problem, the code should look like this:

[code]<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("memberdir") or die(mysql_error());

$appusername = $_POST['login_name'];
$apppassword = $_POST['password'];

$result = mysql_query("SELECT * FROM `user` WHERE username = '$appusername' AND password = '$apppassword'");
if (mysql_num_rows($result) > 0) {
  $_SESSION['authenticatedUser'] = $appusername;
  header("Location: loggedon.php");
}
else {
  $_SESSION['message'] = "Could not connect as $appusername";
  header("Location: login.php");
}
?>[/code]

Regards
Huggie
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.