dolcezza Posted December 8, 2007 Share Posted December 8, 2007 I set a cookie, and the cookie is showing in my system. I can navigate to the next page (contactspage.php) which is protected by cookie without a prob. This is a contacts database click "add" to go to insert.php (inserts info i database) and try to redirect back to contactspage.php it says not logged in. Any help? I am a pretty new, so any help is appreciated. insert.php: <?php include_once('connect.php'); $last=$_POST['last']; $first=$_POST['first']; $venue=$_POST['venue']; $phone=$_POST['phone']; $mobile=$_POST['mobile']; $fax=$_POST['fax']; $email=$_POST['email']; $website=$_POST['website']; $address=$_POST['address']; $city=$_POST['city']; $state=$_POST['state']; $zip=$_POST['zip']; $notes=$_notes['notes']; $query = "INSERT INTO contacts (last,first,venue,phone,mobile,fax,email,website,address,city,state,zip,notes) VALUES ('$last','$first','$venue','$phone','$mobile','$fax','$email','$website','$address','$city','$state','$zip','$notes')"; header('Location: http://www.katzconnects.com/admin/contactspage.php'); $my_result=mysql_query($query); if(!$my_result){echo mysql_error();} ?> contactspage.php: <?php include("config.php"); $cookuser = $_COOKIE["cookuser"]; $cookpass = $_COOKIE["cookpass"]; $adminpass = md5($adminpass); if($cookuser && $cookpass) { if(($cookuser == $adminuser) && ($cookpass == $adminpass)){ echo("Hello Susan!"); ?> <a href=logout.php><img src="buttons/logout_0.jpg" alt="Log Out Button" border="0"></a> <a href=addcontact.php><img src="buttons/add_0.jpg" alt="Add" border="0"></a><br /> <? include_once("contacts.php"); } else{ echo($incorrect_error); } } else{ echo($not_loggedin); } ?> included contacts.php: <?php include_once("connect.php"); $id=$_GET['id']; $query="SELECT * FROM contacts ORDER BY last ASC"; $result=mysql_query($query); // count how many rows are in the table $num=mysql_num_rows($result); mysql_close(); ?> <table border="0" cellspacing="1" cellpadding="2"> <tr bgcolor="#3333ff" > <th>Name</th> <th>Venue</th> <th>Phone</th> <th>Mobile</th> <th>Fax</th> <th>E-mail</th> <th>Website</th> <th>Address</th> <th>City</th> <th>State</th> <th>Zip</th> <th>Notes</th> <th>Delete</th> <th>Edit</th> </tr> <?php //loop if ($num==0) {echo"The database contains no records";} else { $i=0; while($i<$num){ $id=mysql_result($result,$i,"id"); $first=mysql_result($result,$i,"first"); $last=mysql_result($result,$i,"last"); $venue=mysql_result($result,$i,"venue"); $phone=mysql_result($result,$i,"phone"); $mobile=mysql_result($result,$i,"mobile"); $fax=mysql_result($result,$i,"fax"); $email=mysql_result($result,$i,"email"); $website=mysql_result($result,$i,"website"); $address=mysql_result($result,$i,"address"); $city=mysql_result($result,$i,"city"); $state=mysql_result($result,$i,"state"); $zip=mysql_result($result,$i,"zip"); $notes=mysql_result($result,$i,"notes"); $r = 0; while($db_fetch = mysql_fetch_array($result)) { if($i%2 == 0) { echo "<tr bgcolor='#e3e3f4'>"; $r++; } else { echo "<tr bgcolor='#ffffff'>"; $r++; } } ?> <td><? echo $last.", ".$first; ?></td> <td><? echo $venue; ?></td> <td><? echo $phone; ?></td> <td><? echo $mobile; ?></td> <td><? echo $fax; ?></td> <td><a href="mailto:<? echo $email; ?>">E-mail</a></td> <td><? echo $website; ?></td> <td><? echo $address; ?></td> <td><? echo $city; ?></td> <td><? echo $state; ?></td> <td><? echo $zip; ?></td> <td><? echo $notes; ?></td> <td><a href='delete.php?id=<?=$id;?>'><delete><img src="buttons/delete.png" border="0" alt="delete"></a></td> <td><a href='updatepage.php?id=<?=$id;?>'><img src="buttons/edit.png" border="0" alt="edit"></a></td> </tr> <? $i++; } } echo "</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/80739-cookie-set-then-after-function-not-logged-in/ Share on other sites More sharing options...
BenInBlack Posted December 8, 2007 Share Posted December 8, 2007 I don't see your cookie set statement, that would help in helping Link to comment https://forums.phpfreaks.com/topic/80739-cookie-set-then-after-function-not-logged-in/#findComment-409593 Share on other sites More sharing options...
revraz Posted December 8, 2007 Share Posted December 8, 2007 You should also go back and change all your <? tags to <?PHP Link to comment https://forums.phpfreaks.com/topic/80739-cookie-set-then-after-function-not-logged-in/#findComment-409711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.