Jump to content

Recommended Posts

hello when i put in my script i get a server error

 

The website encountered an error while retrieving http://www.webiste.com/storeadmin/admin_login.php. It may be down for maintenance or configured incorrectly.

Here are some suggestions:

Reload this webpage later.

HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

 

<?php
session_start();
if (isset($_SESSION["manager"])){
header("location:index.php");
exit();
}
//check if their loged in
?>
<?php
if (isset($_POST["username"])&&isset($_POST["password"])){

$manager = preg_replace('#[^A-Za-z0-9]#i',",$_POST["username"]);
$password = preg_replace('#[^A-Za-z0-9]#i',",$_POST["password"]);
//connect to db
include"../storescripts/connect.php";
$sql = mysql_query("SELECT id FROM admin WHERE username ='$manager' AND password='$password' LIMIT 1");
//make sure manager exsits
$exsitCount = mysql_num_rows($sql);//counts the rows nums
if($exsitCount == 1){
   while($row = mysql_fetch_array($sql)){
	   $id= $row["id"];
}
$_SESSION["id"]=$id;
$_SESSION["manager"]=$manager;
$_SESSION["password"]=$password;
header("location:index.php");
exit();
}else{
	echo 'That information is incorrect, try again <a href="index.php">Click here</a>';
	exit();
}
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<div align="center" id="mainWrapper">
<?php include_once("../header.php");?>
<div id="pagecontent"><br />
<div align="left" style="margin-left:24px;">
  <h2>Please Log In To Manage The Store</h2>
<form id="form1" name="form1" method="post" action="admin_login.php">
User Name:<br />
<input name="username" type="text" id="username" size="40"/>
<br /><br />
Password:<br />
<input name="password" type="password" id="password" size="40"/>
<br />
<br />
<br />
<label>
<input type="submit" name="button" id="button" value="Login" />
</label>
</form>
<p> </p>
</div>
<br />
<br />
<br />
</div>
<?php include_once("../footer.php");?>
</div>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/246189-re-server-error/
Share on other sites

Chances are your server is not setup to handle errors nicely. As such it throws a 500 error. What this generally means is that you have a syntax error in your code, which looking at the syntax highlighting you do. You could check the /var/log/apache2/error.log file and it will tell you where the error is for future reference.

 

$manager = preg_replace('#[^A-Za-z0-9]#i',",$_POST["username"]);

 

Should be:

 

$manager = preg_replace('#[^A-Za-z0-9]#i',"," . $_POST["username"]);

 

And that would at least resolve that syntax error.

Link to comment
https://forums.phpfreaks.com/topic/246189-re-server-error/#findComment-1264382
Share on other sites

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.