Jump to content

Clicking Submit logs me out??


richo89

Recommended Posts

Hi guys, i've got an admin page where the user enters a customers email address and then hits submit to bring up the results.

 

However, when I click submit it takes me to login.php for some unknown reason. It works perfectly when I tested it locally - however now I have uploaded to my hosting it does not work????

 

Here is my code:

 

<?php
require "config.php";

session_start();

if (!isset($_SESSION['email']))
{
header("Location: login.php");
}
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="Plate Pad Description" />
<meta name="keywords" content="Plate Pad Keywords" />
<meta name="author" content="Plate Pad - Find the perfect personalised registration" />
<link rel="stylesheet" type="text/css" href="styles.css" title="Plate Pad" media="screen,projection" />
<title>Plate Pad - Find the perfect personalised registration</title>
</head>

<body>

<div id="container">
<div id="header">
<div id="subcontent">
	<div class="small box">
		<strong><center><?
$query = mysql_query("select (select count(*) from current) + (select count(*) from prefix)");
list($number) = mysql_fetch_row($query);
echo "$number";
echo "<br>";
echo "Number Plates";
?> </strong></center>	</div>
		</div>
</div>

<div id="navcontainer">
<ul id="navlist">

	<li><? echo "Logged in: ". $_SESSION['email']; ?></li>
	<li>   </li>
	<li><a href="loginAdmin.php">My Account</a></li>
	<li><a href="logout.php">Logout</a></li>


	</ul>
</div>

<div id="content">
<h1>PlateTrader Administrator</h1>

<div class="contentFull">
		<h3>Edit Customer Record</h3>
		<A HREF="javascript:history.go(-1)"> [Go Back]</A>
		<br>

		<table width="35%">
		<tr>
		<td>Enter Customer Email:</td>
		<td><form action="loginAdminEditCust.php" method="GET">
		<input type="text" size="22" name="custEmail">
		</td>
		</tr>
		</table>
		<style type=text/css>
input.button {background-color: #000000; font-weight: bold; font-size: 12px; color: white;}
</style><input class="button" type="submit" name="submit" value="SEARCH">

</form>

<?PHP

$email = $_GET['custEmail'];

$page_name="loginAdminEditCust.php"; 

@$column_name=$_GET['column_name'];

$start=$_GET['start'];								
if(!($start > 0)) {                       
$start = 0;
}

$eu = ($start - 0); 
$limit = 1;                                
$this1 = $eu + $limit; 
$back = $eu - $limit; 
$next = $eu + $limit; 

$query2=" SELECT * FROM customer WHERE Email LIKE '$email'";
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);

$query=" SELECT * FROM customer WHERE Email LIKE '$email'";
if(isset($column_name) and strlen($column_name)>0){
$query = $query . " order by $column_name";
}
$query = $query. " limit $eu, $limit ";
$result=mysql_query($query);
echo mysql_error();

echo "<table border=0 width=100%>"; 

while($noticia = mysql_fetch_array($result)) 
{ 
if($bgcolor=='#f3efef'){$bgcolor='#f3efef';} 
else{$bgcolor='#f3efef';} 
echo "<tr >";
echo "<td width='%' align=left valign='center' bgcolor=$bgcolor id='platemore'> CustomerID: $noticia[Customer_ID]  </td>";
echo "<tr >";
echo "<td width='%' align=left valign='center' bgcolor=$bgcolor id='platemore'> $noticia[Title] $noticia[Firstname] $noticia[surname]  </td>";
echo "<tr >";
echo "<td width='%' align=left valign='center' bgcolor=$bgcolor id='platemore'> $noticia[Address1]</td>";
echo "<tr >";
echo "<td width='%' align=left valign='center' bgcolor=$bgcolor id='platemore'> $noticia[Address2] </td>";
echo "<tr >";
echo "<td width='%' align=left valign='center' bgcolor=$bgcolor id='platemore'> $noticia[Address3]</td>";
echo "<tr >";
echo "<td width='%' align=left valign='center' bgcolor=$bgcolor id='platemore'> $noticia[City]</td>";
echo "<tr >";
echo "<td width='%' align=left valign='center' bgcolor=$bgcolor id='platemore'> $noticia[Postcode]</td>";
echo "<tr >";
echo "<td width='%' align=left valign='center' bgcolor=$bgcolor id='platemore'> Telephone: $noticia[Telephone]</td>";
echo "<tr >";
echo "<td width='%' align=left valign='center' bgcolor=$bgcolor id='platemore'>  Email Address: $noticia[Email]  </td>";
echo "<tr >";
echo "<td width='%' align=left valign='center' bgcolor=$bgcolor id='platemore'> Password: $noticia[Password]  </td>";
echo "<tr >";
echo "<td width='%' align=left valign='center' bgcolor=$bgcolor id='platemore'><a href='loginAdminEditCustInd.php?Customer_ID=".$noticia['Customer_ID']."&Title=".$noticia['Title']."&Firstname=".$noticia['Firstname']."&Surname=".$noticia['Surname']."&Address1=".$noticia['Address1']."&Address2=".$noticia['Address2']."&Address3=".$noticia['Address3']."&City=".$noticia['City']."&Postcode=".$noticia['Postcode']."&Telephone=".$noticia['Telephone']."&Email=".$noticia['Email']."&Password=".$noticia['Password']."'> EDIT  </td>";
echo "<tr >";
echo "<td colspan='7'> <hr> </td>";
echo "</tr>"; 


}
echo "</table>";

echo "<table align = 'center' width='50%'><tr><td  align='left' width='30%'>";

if($back >=0) { 
print "<a href='$page_name?start=$back&column_name=$column_name&prefix=$prefix&prefix2=$prefix2&prefix3=$prefix3&prefix4=$prefix4&prefix5=$prefix5'><font face='Verdana' size='2'>PREV</font></a>"; 
} 

echo "</td><td align=center width='30%'>";
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit){
if($i <> $eu){
echo "<a href='$page_name?start=$i&column_name=$column_name&prefix=$prefix&prefix2=$prefix2&prefix3=$prefix3&prefix4=$prefix4&prefix5=$prefix5'><font face='Verdana' size='2'>$l</font></a> ";
}
else { echo "<font face='Verdana' size='4' color=red>$l</font>";}  
$l=$l+1;
}

echo "</td><td  align='right' width='30%'>";

if($this1 < $nume) { 
print "<a href='$page_name?start=$next&column_name=$column_name&prefix=$prefix&prefix2=$prefix2&prefix3=$prefix3&prefix4=$prefix4&prefix5=$prefix5'><font face='Verdana' size='2'>NEXT</font></a>";}
echo "</td></tr></table>";

?>

		</div>



	</div>

	<div id="footer">
	<p>© 2009 Richard Dawson | Dawsonz Website Design & Photography</p>
</div>

</div>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/168001-clicking-submit-logs-me-out/
Share on other sites

Add the following two lines of code immediately after your first opening <?php tag -

 

ini_set("display_errors", "1");
error_reporting(E_ALL);

 

And add an exit; statement after your header() redirect statement to prevent the remainder of the code on that page from being executed while the browser performs the redirect.

Just ammended what that error was originally there.

 

Now getting this:

 

Notice: Undefined index: custEmail in /home/richo/public_html/platepad/loginAdminEditCust.php on line 77

Notice: Undefined index: start in /home/richo/public_html/platepad/loginAdminEditCust.php on line 83

Here's a question: are you sending custEmail and start to the URL as GET data?

 

These errors (Undefined index) occur when you're trying to access elements in an array that don't actually exist. Which means that $_GET['custEmail'] and $_GET['start'] don't actually exist.

 

Now, I've run in to these errors a lot in the past. They happen if $_GET['whatever'] appears in your code anywhere even if it's not necessarily being used; like if it's inside a nested if statement that doesn't activate. What I ended up doing is wrapping them in one additional if statement that checks to see if they even exist.

 

<?php
if (isset($_GET['whatever'])) {
// do something with $_GET['whatever']
}
?>

 

All I can say is try to knock out those errors one at a time and hopefully you'll find your solution

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.