PHP - Problem With Isset On Form
I have a form that is supposed to use PHP to display errors next to incomplete form fields when the form is submitted.
But I am never getting into my PHP loop. I tried using the print_r(true) function to debug, but no luck. When I click submit I see this i the URL... http://localhost/00_MyWebSite/zzEmptyPHP.php?firstName=&lastName=&submit=Process+Order&submitted=true which is what I would expect on a blank form being submitted. Here is my code... Code: [Select] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link type="text/css" rel="stylesheet" href=".css"> <style type="text/css" > form{ width: 400px; margin: 0 auto; } </style> </head> <body> <?php // Initialize. $errors = array(); $errors['firstName'] = ''; $errors['lastName'] = ''; $firstName = $lastName = ''; echo "print_r = " . print_r(true); if (isset($_POST['submit'])){ // Handle Form. // Trim all incoming data. $trimmed = array_map('trim', $_POST); // Check First Name. if (preg_match('/^[A-Z\'.-]{2,20}$/i', $_POST['firstName'])){ $firstName = $_POST['firstNamae']; }else{ $errors['firstName'] = 'Please enter your First Name.'; } // Check Last Name. if (preg_match('/^[A-Z\'.-]{2,20}$/i', $_POST['lastName'])){ $lastName = $_POST['lastName']; }else{ $errors['lastName'] = 'Please enter your Last Name.'; } // if there are errors then go back to the form and display them }else{ } ?> <form action=""> <fieldset> <legend>Billing Details</legend> <ol> <li> <label for="firstName">First Name:</label> <input id="firstName" name="firstName" class="text" type="text" /> <?php echo $errors['firstName']; ?> </li> <li> <label for="lastName">Last Name:</label> <input id="lastName" name="lastName" class="text" type="text" /> <?php echo $errors['lastName']; ?> </li> </ol> <input type="submit" name="submit" value="Process Order" /> <input type="hidden" name="submitted" value="true" /> </fieldset> </form> </body> </html> Any ideas what I am doing wrong? Thanks, Debbie Similar TutorialsHey Guys, Im working with a form and need some help. So at the moment i have got it working so that if the user doesn't select the values from the drop down list, an error will occur saying 'Please select all fields'. What i want to do now is make it so that if this error occurs, the value of the drop down list will stay as it is an NOT reset. Could someone help me out? * Note that the code below is currently ok, basically it checks if there is a value, if not it will say "Select Player". Code: [Select] <td>Prop</td> <td><select name="prop1" style="width: 150px"> <option value="<? echo $row['prop1']; ?>"><? if (empty($row['prop1'])) { echo "Select Player"; } else { echo $row['prop1']; } ?></option> <?php echo $option_str; ?> </select></td> <td>16.</td> <td><select name="r16" style="width: 150px"> <option value="<? echo $row['r16']; ?>"><? if (empty($row['r16'])) { echo "Select Player"; } else { echo $row['r16']; } ?></option> <?php echo $option_str; ?> </select></td> Hi all, Hoping someone can help with what i would guess is a very simple problem. I have the following code which is suppose to display a form. the form posts to itself and uses isset and if the form has been posted it doesnt display the form. if (isset($_POST['submit'])) { echo "question submitted successfully"; } else { echo '<form method="post" name="qanda" id="qanda" action="http://' . $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] . '">'; echo '<p><label for="name">Name</label> <input type="text" id="name" /></p>'; echo '<p><label for="e-mail">E-mail</label> <input type="text" id="e-mail" /></p>'; echo '<p><label for="Question">Question</label> <textarea rows="6" id="question"></textarea></p>'; echo '<p class="submit"><input type="submit" value="Submit" /></p></form>'; } this currently doesnt work. Extra things you might need to know is that this script/form is an included file in a dynamic site which also uses the rewrite module which is why I am using http://' . $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] just incase that makes a difference. I've tried both of these methods, but neither are working. The if statement fails every time. Code: [Select] if(isset($_POST['submit'])){ Code: [Select] if(isset($submit)){ This is the form: Code: [Select] <form id="form1" name="form1" method="post" action="join.php"> <label><span> <input name="email" type="text" class="keywords" id="textfield" maxlength="50" value="Join my mailing list..." onclick="make_blank();" /> </span> <input name="submit" type="image" src="images/search.gif" class="button" onclick="return checkmail(this.form.email);"/> </label> </form> Hi guys I am trying to create a page where if a selection has not been made then a jump menu is displayed listing all of the fixtures for a season, if a selection has been made then at present I want it to show Enter match info, however when a match is selectd it goes to a yahoo search page, as if the page cannot be found, the code I have used is below, any ideas what I have done wrong? The page can be seen at www.yardleyheroes.co.uk/admin/edit_result.php Code: [Select] <h1>Submit Results</h1> <?php if (isset ($_GET['match_id'])) { echo('Enter match info'); } else { $con = mysql_connect('localhost', 'user', 'password', true); if(!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db('dbname', $con); echo('<form name="form" id="form">'); echo('<select name="jumpMenu" id="jumpMenu" onChange="MM_jumpMenu(\'parent\',this,0)">'); $fixtures=mysql_query('SELECT * FROM `fixtures` where current=1 ORDER BY `match_date`'); if(mysql_num_rows($fixtures)==0) echo('<option>there is no data in table..</option>'); else echo('<option selected="selected">Please select the match</option>'); { while($matchrow=mysql_fetch_assoc($fixtures)) { echo ('<option value="edit.php?match_id='.$matchrow['match_id'].'">'.date("d-M-Y", strtotime($matchrow['match_date'])).'|'.$matchrow['Opposition']."</option>"); } } echo('</select>'); echo('</form>'); } ?> [/cod] Hi guys, first time posting here. Anyway, heres my problem. I have this section of code at the beggining of my page: Code: [Select] if (isset($_POST['userChoice'])) { $try = check_word($_POST['userChoice']); echo ("We are into the loop"); } else { echo ("<br/>about to call change word"); changeword(); echo ("<br/> we called the changeword"); } And here is my form: Code: [Select] <html> <head> </head> <body> <form name="wordguess" action="Index.php" method="POST"> <table> <tbody> <tr> Try to guess what the following word is: <?=$scrambled ?> <br/> </tr> <tr> Your Guess: <input type="text" id="userChoice" size="20" /> <br/> </tr> <tr> <td> <input type="submit" name="submit" id="submit" value="Submit"> </td> </tr> <tr> <?=$correct?> </tr> </tbody> </table> </form> </body> </html>' Now, how i assumed it worked was that the first time the page is loaded it would display the form and that's it. However, even when they hit the submit button on the form, its not really doing the POST, so when the page reloads, gives me the same stuff so it always goes on the else part of the if. Any help would be appreciated. Thanks, GoodVibe I'm having a problem where when I click the "use" link it only displays my check message which is "Hey", but for some reason I have to click it again for my queries to work. Here's a pick: . Here's the code: Code: [Select] <?php if(isset($_SESSION['user'])){ include_once('connect.php'); $session = $_SESSION['user']; echo " <br/> <div class='profile-general-stats'> <table> <th>Item Name</th><th>Description</th><th>Use/Sell</th> "; $yo = "SELECT * FROM player_items WHERE Username = '$session' ORDER BY id ASC"; $check = mysql_query($yo) or die (mysql_error()); $num_of = mysql_num_rows($check); if($num_of > 0){ while ($is = mysql_fetch_array($check)){ $item_id = $is['id']; $item_name = $is['Name']; $item_type = $is['Type']; $item_value = $is['Value']; $item_description = $is['Description']; $item_sell_value = $is['Sell_Price']; echo " <tr> <td align='left' style='padding: 5px; padding-left: 25px;'><strong>$item_name</strong></td> <td align='left' style='padding: 5px;'>$item_description</td> <td align='middle' style='padding: 5px;'><a href='?use&id=$item_id&name=$item_name&type=$item_type&value=$item_value'>Use</a> | <a href='#sell_$item_name' id='$item_id'>Sell</a></td> </tr> "; } }else{ echo " <tr> <td align='left' style='padding: 5px; padding-left: 25px;'>No Items</td> <td align='left' style='padding: 5px;'>No Items</td> <td align='middle' style='padding: 5px;'>No Items</td> </tr> "; } echo " </table> </div> "; if(isset($_GET['use'])){ echo "Hey"; $use_id = $_GET['id']; $use_name = $_GET['name']; $use_type = $_GET['type']; $use_value = $_GET['value']; if($use_type == "Credits"){ $use_type = "Current_Credits"; } $check_item = "SELECT id FROM player_items WHERE id = '".mysql_real_escape_string($use_id)."' AND Username = '".$_SESSION['user']."'"; $run_check = mysql_query($check_item) or die(mysql_error()); $num_check = mysql_num_rows($run_check); $e = mysql_fetch_array($run_check); $item_stat = "SELECT `".$use_type."` FROM stats WHERE Username = '".$_SESSION['user']."'"; $run_stat = mysql_fetch_array(mysql_query($item_stat)) or die (mysql_error()); $new_stat = $run_stat[''.$use_type.'']; if($num_check == 1){ $new_stat = $new_stat + $use_value; mysql_query("UPDATE stats SET `".$use_type."` = '".mysql_real_escape_string($new_stat)."' WHERE Username = '".mysql_real_escape_string($_SESSION['user'])."'") or die(mysql_error()); mysql_query("DELETE FROM player_items WHERE id = '$use_id'") or die(mysql_error()); }else{ } }else{ } }else{ header("Location: index.php"); } ?> Hey, I've got a site and I need to query a database to check if there is a result. If there isnt then I need a default result... //Check the database and get a result $skinName = strtolower(get_post_meta($post_id, $key, $single)); if (isset($skinName)) { //If there is a result, then use it $skinName = strtolower(get_post_meta($post_id, $key, $single)); } else { //If NO result then use RED $skinName = 'red'; } //Build up the var to show REDsite $skinName = $skinName . 'site'; For some reason the above doesnt work. If there is a result then it uses it, however if there is no result then it simply shows "site" - not "redsite" like it should do. Any ideas what I missed? Hi, I have a form on my page. <form id="advanced_search" name="advanced_search" method="POST" action="<?php echo $PHP_SELF;?>"> </form> Form submits with a regular button <input type="submit" name="advSearch" id="advSearch" value="Search" /> And i have a detector to see where submit button has been clicked on my next page: if(isset($_POST['advSearch'])) { echo "Button was clicked"; } However, I wanted a custom button for better styling and control. So i replaced my regular button with this now which uses javascript to submit the form. <a class="button" href="javascript:document.advanced_search.submit()" name="advSearch" id="advSearch"><span>Search</span></a> Now the isset($_POST) is not working anymore. Can anyone help please?? Thanks! Hi. Link to project: www.smarttreff.moo.no Login user: admin login pw: 123 When i login the login form wont disapear. If i return to the index(Hjem) page without logging out, the loginform disapear. I am ussing session for the login So the basicly, i want the loginform do disapear at once when the user has pushed login button(Logg in) (dont laught at my "cut and past" for the include meny.. i just made the design and chopped it to bits and put it into includes) Index.php Code: [Select] <?php session_start(); include("css.php"); include("header.php"); include("meny.php"); ?> <td width="596" valign="top"><table width="100%" border="0" cellpadding="15"> <tr> <td class="tabell" valign="top" align="left"> Main </td> </tr> </table></td> </tr> </table> <?php include("footer.php"); ?> meny.php Code: [Select] <table width="800" border="0"> <tr> <td width="198" valign="top"><table width="100%" border="0" cellpadding="15"> <tr> <td align="left" valign="top" class="tabell"> <a href="index.php">Hjem</a> <br /> Når og hvor <br /> For hvem <br /> Spørsmål og svar<br /> Forum <br /> <br /> <br /> Samarbeidspartnere </td> </tr> </table> <br /> <table width="100%" border="0" cellpadding="15"> <tr> <td class="tabell" valign="top" align="left"> <?php if(isset($_SESSION['username'])) echo "Velkommen, " .$_SESSION['username']. "!<a href='innlogget.php'>Medlemsnyheter</a><br><a href='logout.php'>Log ut</a>"; else { include("loginform.php"); } ?> </td> </tr> </table></td> <td width="15"> </td> I'm having a few issues with a serach function in Internet Explorer, it works fine in firefox which is very annoying. What basically is happening, is the a form is sumbitting and posting info across, but on itself and then this is transfered into a php variable which is used on the query. Default values have been assigned if the isset of the form is not true. So I believe the issue is occuring on the " if(isset($_POST['submit'])) " but as stated it works perfectly fine in firefox. Any suggestions? Code: [Select] <?php print " <form target='_self' method='POST'> <table class=''> <tr> <td> <input name='vehicle' type='text' id='search_name' size='16'> <input type='image' src='images/search.gif' alt='Search' name='submit' id='search' value='Search'/> </td> </tr> <tr> <td> <select name='filter' id='filter'> <option value='make' selected='selected'>Filter By</option> <option value='make'>Vehicle Manufacture</option> <option value='model'>Vehicle Model</option> <option value='our_price'>Price</option> <option value='delivery_time'>Delivery Time</option> </select> </td> </tr> <tr> <td> <input type='radio' name='direction' value='ASC' checked/>Ascending <input type='radio' name='direction' value='DESC' />Descending </td> </tr> </form> "; include "connections/dbconnect.php"; if(isset($_POST['submit'])) { $vehicle = $_POST['vehicle']; $filter = $_POST['filter']; $direction = $_POST['direction']; //$rowsPerPage = $_POST['limit']; } else { $filter = "make"; $direction = "ASC"; } //$manfactures = "Ford"; if(isset($_GET['limit'])) { $rowsPerPage = $_GET['limit'];; } else { // how many rows to show per page $rowsPerPage = 10; } // by default we show first page $pageNum = 1; // if $_GET['page'] defined, use it as page number if(isset($_GET['page'])) { $pageNum = $_GET['page']; } // counting the offset $offset = ($pageNum - 1) * $rowsPerPage; $car_query = " SELECT * FROM cars WHERE model LIKE '%$vehicle%' OR make LIKE '%$vehicle%' OR model_details LIKE '%$vehicle%' OR search LIKE '%$vehicle%' ORDER BY $filter $direction LIMIT $offset, $rowsPerPage"; $car_result = mysql_query($car_query) or die ("Error in query: $car_query. ".mysql_error()); setlocale(LC_MONETARY, 'en_GB'); $fmt = '%i'; // how many rows we have in database $query = "SELECT COUNT(model) AS numrows FROM cars"; $result = mysql_query($query) or die('Error, query failed'); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numrows = $row['numrows']; // how many pages we have when using paging? $maxPage = ceil($numrows/$rowsPerPage); // print the link to access each page $self = $_SERVER['PHP_SELF']; $nav = ''; for($page = 1; $page <= $maxPage; $page++) { if ($page == $pageNum) { $nav .= " $page "; // no need to create a link to current page } else { $nav .= " <a href=\"$self?page=$page&limit=$rowsPerPage\">$page</a> "; } } if ($pageNum > 1) { $page = $pageNum - 1; $prev = " <a href=\"$self?page=$page&limit=$rowsPerPage\">[Prev]</a> "; $first = " <a href=\"$self?page=1&limit=$rowsPerPage\">[First Page]</a> "; } else { $prev = ' '; // we're on page one, don't print previous link $first = ' '; // nor the first page link } if ($pageNum < $maxPage) { $page = $pageNum + 1; $next = " <a href=\"$self?page=$page&limit=$rowsPerPage\">[Next]</a> "; $last = " <a href=\"$self?page=$maxPage&limit=$rowsPerPage\">[Last Page]</a> "; } else { $next = ' '; // we're on the last page, don't print next link $last = ' '; // nor the last page link } if (mysql_num_rows($car_result) > 0) { ...... bringing back all the information from the database I am having problems with my $_GET. When a user chooses an Article from "article_index.php", they click on a hyperlink, e.g. Code: [Select] <a href="<?php echo BASE_URL; ?>articles/postage-meters-can-save-you-money"> This triggers my Mod_Rewrite... Code: [Select] RewriteEngine on #PRETTY: articles/postage-meters-can-save-you-money #UGLY: article.php?slug=postage-meters-can-save-you-money RewriteRule articles/([a-zA-Z0-9_-]+)$ article.php?slug=$1 Which should take them to "article.php?slug=postage-meters-can-save-you-money" and then this code is supposed to grab the "slug" and retrieve the Article... Code: [Select] // Attempt to Retrieve Article. if (isset($_GET['slug'])){ // Slug found in URL. // Set Slug. $slug = $_GET['slug']; That part is working fine, however, if I go into the Address Bar and delete out the slug, so my URL looks like this... Code: [Select] www.MySite.com/articles/"> I would expect the ELSE part of the above code to kick in... Code: [Select] }else{ // Slug not found in URL. header("Location: " . BASE_URL . "index.php"); }//End of ATTEMPT TO RETRIEVE ARTICLE Unfortunately I am just getting this error... Quote Not Found The requested URL /articles/ was not found on this server. Apache/2.0.59 (Unix) PHP/5.2.6 DAV/2 Server at local.debbie Port 80 Why is my ELSE not detecting that there is no slug?? Debbie Hi, I'm very new to PHP so I hope this is not frustrating. I'm having trouble understanding how "isset" works. I'm trying to get it so that when I click a button, it returns two variables(in an array). This works, but I tried to use "Isset" to detect if a array was created, then alter the variable. It's not working... I'm not too sure where I'm going wrong, could anyone give me some advice? Thanks
<?php if(isset($_POST['name'])) { $userAnswer = $_POST['name']; if(isset($_SESSION['test'])){ $_SESSION['test'][$userAnswer]['var1']++; $test = $_SESSION['test'][$userAnswer]; foreach ($test as $key){ echo json_encode($key); }; } else { $test = $_SESSION['test'][$userAnswer]=array("var1" => 1, "var2" => 2); foreach ($test as $key){ echo json_encode($key); }; } } ?> $(document).ready(function(){ $("button").click(function(){ var test = "here"; $.ajax({ url: 'info.php', type: "POST", dataType:'json', data: ({name: test}), success: function(data){ $("#click").fadeOut(function() { $(this).append(data); }).fadeIn(); } }); }); }); I am an absolute beginner in php & am trying to validate a form using javascript. Problem is I am checking if the textbox is left empty before the user clicks on the submit button(using javascript). On the other hand i'm using isset function of php for the same submit button so that it does not run the code unless and until the button is clicked. Due to this, the default value of text box is being entered into database. How do i prevent this? Is there an alternate function to isset for such an event? Here is a sample code Code: [Select] <?php if(isset($_POST[sub])) $sql="insert into testing values('$_POST[txt1]')"; $exec = mysql_query($sql); ?> <script type="text/javascript"> function check() { var a = document.getElementById('add'); if (a.value = "") { return false; } } </script> <form action="add.php" method="post"> <input type="text" name="txt1" id="add"><br> <input type="submit" name="sub" value="Click to Add" onclick = "check();"> </form> I'm using ghost text technique on my page instead of labels so the text boxes have different values at different instances and hence I cant use !empty function either. How do i unset the submit button so that it does not run the script further? When the form is summited it is supposed to check if the password field contained any text so that way it updates the password. so only if $password exists should it run that query. I tried all different ways of making that happen and it never works. I will summit the form without anything in the password field and it will still update the password to something encrypted in md5 anyways. Code: [Select] <?php include ('header.php'); if(isset($_GET['sa'])) { switch ( $_GET['sa']) { case 'edit': edit(); break; } }else{ echo "<div class='header'>Edit admins</div><div class='content'>"; $query = mysql_query("SELECT * FROM `admins`"); while($row = mysql_fetch_array($query)){ $username = clean_up($row['username']); $id = clean_up($row['id']); $email = clean_up($row['email']); $website = clean_up($row['website']); echo "$id $username $email $website | <a href='index.php?action=editadmins&sa=edit&id=$id'> Edit</a><br>"; } echo "</div>"; } function edit() { $id = clean_up($_GET['id']); if(isset($_POST['submit'])){ $username = clean_up($_POST['username']); $password = md5(clean_up($_POST['password'])); $email = clean_up($_POST['email']); $website = clean_up($_POST['website']); if(isset($username)){ if(isset($password)){ mysql_query("UPDATE `admins` SET `password`='$password' WHERE `id`='$id'"); } mysql_query("UPDATE `admins` SET `username`='$username', `email`='$email', `website`='$website' WHERE `id`='$id'"); echo "<b><font color=green>Information edited. Go <a href='index.php'>home</a>?</font></b><br>"; }else{ echo "please enter a username"; } }else{ $query = mysql_query("SELECT * FROM `admins` WHERE `id`='$id'"); while($row = mysql_fetch_array($query)){ $username = clean_up($row['username']); $email = clean_up($row['email']); $website = clean_up($row['website']); echo "<div class='header'>Edit $username</div><div class='content'><form action='index.php?action=editadmins&sa=edit&id=$id' method='post'> <b>Username:</b> <input type='text' name='username' id='username' value='$username'><br> <b>Password:</b>(leave blank to keep same) <input type='password' name='password' id='password' value=''><br> <b>Email:</b> <input type='text' name='email' id='email' value='$email'><br> <b>Website:</b> <input type='text' name='website' id='website' value='$website'><br> <input type='submit' name='submit' id=submit' value='Edit $username'></form></div>"; } } } include('footer.php'); ?> If I wanted to make multiple fields required before letting a User move past the field is this the proper way to do it? Code: [Select] if(isSet($_POST['playerFirst']['playerLast']['feet']['inches']['year']['status'])) { ## Something } else { ## Something else } I am trying to do isset($_GET but I have a bizarre problem come up. I am using "id" as one of my fields but when I try to use it in the code it says it is not recognised. However I use this field quite widely. The code its coming up with is "Undefined variable: id" but I cant see why it has a problem with id. My code is: <?php if(isset($_GET['id'])){ $sql = mysql_query("SELECT * FROM productfeed WHERE id='$id' LIMIT 1"); } { while($row = mysql_fetch_array($sql)) $id = $row['id']; $image = $row['awImage']; $link = $row['link']; $description = $row['description']; $fulldescription = $row['fulldescription']; $price = $row['price']; echo "<div class=\"productdisplayshell\"> <div class=\"productdisplayoutline\"> <div class=\"productborder\"><center> <a href=\"$link\" target=\"_blank\" ><img src=\"$image\" /></a> </center> </div></div> <div class=\"productdescriptionoutline\"><div class=\"productdescriptionbox\"> <a href=\"$link\" target=\"_blank\" >$description</a> </div><div class=\"productfulldescriptionbox\"> $fulldescription </div></div> <div class=\"productpriceoutline\"> <div class=\"productpricebox\"><center>&#163; $price</center></div> <div class=\"productbuybutton\"><center><a href=\"$link\" target=\"_blank\" ><img src=/images/buybutton.png /></a></center></div></div></div>"; } ?> I read ages ago (and checked to see if it's true, it was and given how it works, it must still be) the end user can alter the value of any form field, using Firebug or similar, before submitting it. Two things I've figured out today: 1) a form input doesn't need a value - doesn't even need the attribute - if you're only checking whether the POST var isset and the actual value isn't important 2) Although it appears not to matter in the example I'm working on now, if the script doesn't check what the value is, and potentially sanitise it, the user could submit the form with any value, true, false, malicious, idk... So my question is: is this one of the ways malicious bad things can happen and do I *have to* specify a value, not because the script won't work without it, it does, but because in the real world it opens a security door if I don't check for malicious script by saying "if value not as expected, script has to die". Having formulated the question properly and thought about it I can't imagine simply making a form, without obvious connections to anything important, could be a problem in the way I'm asking about but I asked it now so Edited by appobs, 03 July 2014 - 12:08 PM. Hi all I need to do a multiple if isset to get three variables from the URL. Here is my code for just one: if(isset($_GET['category'])) { $fetchproducts = mysql_query(" SELECT * FROM `products` WHERE category = '".$_GET['category']."'"); while($returnedProduct = mysql_fetch_array($fetchproducts)) { include('product-cell.php'); } How do I combine this to check what is the 'type' and 'colour' from the URL and fetch from the SQL accordingly? Many thanks for you help Pete i Have two page login.php and verify.php In login.php user is entering Username and Password and in the action of the form i am writing verify.php. If verification is a success then i will start a session() Code: [Select] session_start(); $_SESSION['ls']="loggedin"; // ls stands for login status $_SESSION['id']=$row['id']; $_SESSION['user_name']=$row['user_name']; $_SESSION['email']=$row['email']; header('location : members.php'); die (" "); and will redirect them to members.php .... Everything is working fine... But in login.php i have written a code on the top... Code: [Select] <?php if(isset($_SESSION['ls']) && isset($_SESSION['id']) && isset($_SESSION['user_name']) && isset($_SESSION['email']) ) { header('location:members.php'); die(" "); } ?> I want if a session is started and if user will access login.php they will automatically go to members.php But this script is not working... Iam not getting whats the problem... also i m not getting any error login.php or anything CODE WRITTEN ON THE TOP OF members.php IS : Code: [Select] <?php session_start(); if(@$_SESSION['ls']!=="loggedin" ) // Checks if the person has done stage one (Registration.php) { header('Location: login.php'); //If they haven't done it, it sends them back. die (" "); } ?> Isn't this code redundant... if (isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == TRUE){ After all, if $SESSION['logged_in'] == TRUE then it is *obviously* set... Debbie |