Ok, so here's the script I'm working on. I have checked the forums about 5 times now and have changed the script accordingly but nothing seems to fix the problem.
I need to check the user name and password from the form against the database. However, it needs to be case sensitive so I used LIKE. Nothing seems to be working, need someone to check the coding. Maybe php just doesn't like me??
newslogin.php
<?php
session_start();
if (isset($_POST['submit']))
{
require_once ('../db_connect.php');
mysql_select_db("stolenst_news");
$query = "SELECT * FROM users WHERE uname LIKE '%$user%' AND password LIKE '%$password'";
$result = mysql_query($query, $dbc);
$row = mysql_fetch_array ($result, MYSQL_NUM);
if (mysql_num_rows($result) > 0)
{
session_start();
$_SESSION['user_name'] = $user;
$_SESSION['password'] = $password;
header ("Location: news_add.php");
exit();
}
else
{
echo "You user/pass did not match";
}
}
else
{
?>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
User Name:
<br>
<input name="user" type="text">
<br>
<br>
Password:
<br>
<input name="password" type="password">
<br>
<br>
<input type="submit" name="submit" value="Submit" />
<input type="reset" name="reset" value="Reset" />
</form>
<?
}
?>
sends to:
news_add.php
<?php
session_start();
if(!isset($_SESSION['user_name']))
{
header ("Location: newslogin.php");
exit();
}
if (isset($_POST['submit']))
{
require_once ('../db_connect.php');
mysql_select_db("stolenst_news");
$date = date("F j, Y, g:i a");
$query = "INSERT INTO news (auth, name, body, date) VALUES ('$author', '$title', '$body', '$date')";
$result = @mysql_query ($query);
if ($result)
{
echo "Added $title to the news base!";
}
else
{
echo "Something went wrong <br>";
echo "mysql_error()";
}
mysql_close();
}
?>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Author:
<br>
<SELECT NAME="author" id="author">
<OPTION>Select...</OPTION>
<OPTION>Eric</OPTION>
<OPTION>Norma</OPTION>
</SELECT>
<br>
<br>
News Title
<br>
<input name="title" type="text">
<br>
<br>
News Body:
<br>
<textarea name="body" cols="40" rows="5">s</textarea>
<br>
<br>
<input type="submit" name="submit" value="Submit" />
</form>