PHP - Need Help Getting A Login Slider To Disappear When Logged In
Hi all,
I have a problem I am not sure how to sort, hopefully someone here can help. I have a sliding login panel on a website that I am making. Its quite discreet. I have a stripped down version here that you can see: http://mgdesign.hostultra.com/login_test/login_test.php On the page I am making, users with a log in enter their details and will be taken to the restricted page. I would like this sliding panel to be on every page when the user is not logged in. Once they log in from the sliding panel they can still surf around all the main site pages. When they log out the session dies and it reverts to the home page. However, when they are logged in I would like the sliding login panel to disappear from the top of each page. Is there any way I can do this simply? Any help or advice would be greatly appreciated. Similar TutorialsHi. I'm new to php. I created a register, log in, welcome, and log out page for my site. They are all working accordingly. I'm having one problem that I can't seem to fix. I would like to stay logged in as I navigate other pages of my site. Everytime i click on a link to another page within my site I get logged out. I know this issue might pertain to using session but thats all I was able to find using google search. Can anyone help? Much appreciated. Hi, i have a site www.gnetuk.net where people can register and login,. thats all fine but what code can i use on my php pages to see whos logged in im sure its going to be a simple line of code or smthink but i am new to this stuff. PLEASE HELP <G> I have dynamic images that have the "Like" button, it's basically like a wishlist. The way I want it to work is that when a user is not logged in, the 'Like' button will navigate them to a login popup (which I already made). With some great forum help my nav menu shows nav options in the main menu, and when the user logs-in, it lines up additional menu choices all on a horizontal line. The issue I'd like to fix is to make the "log-in" menu choice disappear when the user is logged-in. If you can overlook all the font tags, in the code below, I'd greatly appreciate any help. Code: [Select] <!--Begin Sub-Navigation. This only appears when a user is logged in.--> <div class="sub-nav"> <img src="themes/default/images/arrow-red.gif"> <a href="members/[var.user_name]"><font color="#333333" face="verdana">my account</font></a> <img src="themes/default/images/arrow-red.gif"> <a href="credits.php"><font color="#333333" face="verdana">[var.lang_my_credits]: [var.member_credits]</font></a> <img src="themes/default/images/arrow-red.gif"> <a href="logout.php"><font color="#000000" face="verdana">log out</font></a> <!--[onload;block=div;when [var.loggedin]=1;comm]--> </div> <!--Begin Sub-Navigation. This only appears when a user is logged in.--> <div class="sub-nav1"> <p class="account"> <span id="welc"><span style="color:#333333; font-size: 12px; font-face=verdana;"> Welcome! You Are Now Logged In.</span></p> <!--[onload;block=div;when [var.loggedin]=1;comm]--> </div> <div class="menu1"> <a href="[var.base_url]"> <font color="#333333" font face="verdana">home</font></a> <a href="page.php?page=16"><font color="#333333" face="verdana">faq</font></a> <a href="[var.base_url]/join.php"><font color="#333333" face="verdana">register</font></a> <a href="[var.login_out_link]"><font color="#333333" face="verdana">log in</font></a> <a href="page.php?page=9"><font color="#333333" face="verdana">search</font></a> <a href="page.php?page=6"><font color="#333333" face="verdana">upload</font></a> </div> Code: [Select] .menu1 { font-size: 11px; font-family: verdana; text-align: right; float: right; color: #333333; margin: 0px 5px 0px 0px; padding: 0px 0px 0px 0px; } .sub-nav { font-size: 11px; font-family: verdana; text-align: right; color: #333333; margin: 0px 22px 0px 0px; padding: 0px 0px 0px 0px; } .sub-nav-links { color: #; font-size: 14px; margin: 0px 0px -20px 0px; } .sub-nav1 { font-size: 11px; font-family: verdana; text-align: right; float: left; color: #333333; margin: 0px 22px 0px 0px; padding: 0px 0px 0px 0px; } .sub-nav {float:right} .sub-nav1 p { margin:0 font-size: 11px; font-family: verdana; color: #333333; } #welc{ float left; } .account font-size: 11px; font-family: arial; color: #333333; } This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=343671.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=358408.0 When I asked how to make this Log In Form disappear once it performs it's function:
<form action="../login.php" method="post" accept-charset="UTF-8" class="middletext" onsubmit="javascript:this.style.display='none';"> <p> <input type="text" size="20" name="user_name_login" id="user_name_login" value="ENTER USERNAME" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if (this.value=='ENTER USERNAME') {this.value=''; this.style.color='#696969';}" > <input type="text" size="20" name="password_login" id="password_login" value="ENTER PASSWORD" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if (this.value=='ENTER PASSWORD') {this.value=''; this.style.color='#696969';}" > <input type="hidden" name="cookie_time" value="10080" /> <img src="../themes/default/images/arrow-red.png" alt="" /><input type="submit" style="outline:grey" font-size="5px" value="[var.lang_login_now]" class="button-form2" /> <input type="hidden" name="submitted" value="yes" /> <input type="hidden" name="remember_me" value="remember_me" /> </p> </form> </div> <!--Begin Sub-Navigation. This only appears when a user is logged in.--> <div class="container1"> <div class="menu1"> <div class="sub-nav"><a href="../index.php"></a> <img src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle" alt="" /><a href="../members/[var.user_name]"> my account</a><img src="../themes/default/images/arrow- red.jpg" style="vertical-align:middle" alt="" /> <a href="../credits.php">[var.lang_my_credits]: [var.member_credits]</font></a><img src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle"><a href="../logout.php">[var.login_out]</a> <!--[onload;block=div;when [var.loggedin]=1;comm]--> </div>I was given this line of code: if($_SESSION['loggedin'] == true){ //dont show form } else { //show form }But I don't know how/where to integrate it into the Form. Any help will be appreciated. Ok, I've spent a good part of the day trying to figure out what is going wrong with a client site. I introduced a link within document to send readers from the blogs home page to the comments section of individual posts. It's straight forward right? HTML1, been doing these kind of links for more than ten years. #respond at the end of the normal URL in a normal anchor tag should bring the browser to id="respond" or name="respond" within the document. Right? But, a.) it doesn't. And b.) once it makes a jump everything above that point disappears. Space fills out to the same page height as if it existed but you can't scroll up. You can see it in action at http://www.thebouncingbead.com/blog/ by clicking "Add Your Comment (0)" under the title of any post. Can anyone see what might be causing this problem or experienced something similar before? Alright, so I'm fairly new to PHP coding and I still have a ton to learn, so it's not surprising that I ran into a problem pretty quickly. I've setup a database and even managed to scrap together a SIMPLE member management system. All of it works, but I still need one thing. A lot of sites I visit which allow users to signup have this at the top; Login or Register. Nothing huge, just in the corner, know what I mean? I was wondering how I do this? Also, after someone logs in, how do I change that to show "You are logged in as [username] and then a logout option? I'm just learning about PHP and I'm diving in head first by attempting to modify our web site's contact form. I'm wishing to stop the form from erasing previously entered values upon "failed" data validation. It's of course going to be annoying to our visitors if their hardworked entries disappear just because they left out a name or entered an illegal email address. I regret that some potential solutions found on this forum and other locations on Google didn't seem to help on my page. As you can see, the validation is done with PHP's version of if-elseif-else. Later I'll be adding a reCAPTCHA and I hope that whatever I learn here might be useful for the potentially same problem when I am adding the CAPTCHA. The actual contact form is at http://www.woofwoofwoof.org/contact/index.php. Thank you in advance for your taking the time to help me what originally appeared to be a simple problem. I have read the rules and I hope I've followed the rules -- please let me know if I committed any sins of omission or commission. Now, for your Sunday reading pleasure, here's the code: CODE STARTS HERE ==================================== <?php include("../common/docType.php"); ?> <?php include("../common/htmlOpen.php"); ?> <head> <title><?php include("../common/titleBar.php"); ?> - Contact us!</title> <meta name="description" content="Call or email us with questions or orders."> <meta name="keywords" content="Barking Dog Chocolatiers, Charlotte NC, chocolate, contact us, telephone, email, e-mail"> <meta name="geo.placename" content="Charlotte, North Carolina"> <meta name="geo.region" content="US-NC"> <meta name="author" content="Joal Fischer"> <meta name="verify-v1" content="1aqZs7xrrfI3lp1RaWDkHHjY9UQZIbq2z/mIVdFeXiI=" /> <?php include("../common/headInclude.php"); ?> <script src="../common/common.js" type="text/javascript"></script> <link rel="Stylesheet" href="../css/contact.css" /> </head> <?php // Success/Fail message $msg = ""; $brisket = ""; // Target Email $targetEmail = "barkingdog@bellsouth.net"; // Process Submissions if(isset($_POST['submitted'])) { if($_POST['submitted']) { // process form. $guestName = $_POST['guestName']; $cityState = $_POST['cityState']; $emailAddress = $_POST['emailAddress']; $phone = $_POST['phone']; $msgSubject = "Barking Dog Chocolatiers Inquiry"; $msgContent = "FROM: $guestName\n"; $msgContent .= "City/State: $cityState\n"; $msgContent .= "Phone & time to call: $phone\n"; $msgContent .= "\nInquiry:\n"; $msgContent .= stripslashes($_POST['msgContent']); // Trial if then else reversed from Dan's original allowing maybe multiple tests in sequence -- in action if($guestName == "") { $keepvar = "1"; $msg = "<p style='color: red; font-weight: bold; font-size: 14px; margin: 12px 0px 0px 0px;'>Please enter a name!</p>"; } elseif($emailAddress == "") { $msg = "<p style='color: red; font-weight: bold; font-size: 14px; margin: 12px 0px 0px 0px;'>Please enter a valid email address!</p>"; } else { mail($targetEmail, $msgSubject, $msgContent, "From: $guestName <$emailAddress>\nX-Mailer:PHP/" . phpversion()); $msg = "<p style='color: darkgreen; font-weight: bold; font-size: 14px; margin: 12px 0px 0px 0px;'>Thank you! Your message has been sent.</p>"; $brisket = "<img src='../images/Brisket180x180web.jpg' width='180px' height='180px' alt='Brisket Says Hi' />"; } // Original if then else all commented out // if($emailAddress != "") { // mail($targetEmail, $msgSubject, $msgContent, "From: $guestName <$emailAddress>\nX-Mailer:PHP/" . phpversion()); // $msg = "<p style='color: darkgreen; font-weight: bold; font-size: 14px; margin: 12px 0px 0px 0px;'>Thank you! Your message has been sent.</p>"; // $brisket = "<img src='../images/Brisket180x180web.jpg' width='180px' height='180px' alt='Brisket Says Hi' />"; // } else { // $msg = "<p style='color: red; font-weight: bold; font-size: 14px; margin: 12px 0px 0px 0px;'>Please enter a valid email address!</p>"; // } } } ?> <body onload="loadMe('contact')"> <div id="container"> <div id="header"> <a href="../home/index.php" style="border:none"><div id="logo"></div></a> <div id="navBG"><?php include("../common/mainNav.php"); ?></div> </div><!--End Header--> <div id="contentArea"> <br /><img class="sideBox" src="../images/sideBox.jpg" width="12px" height="12px"><p class="sideItemSelected">contact us</p><br style="clear:both" /> <p class="sideItem"><a class="sideLink" href="./shipping.php">useful q & a</a></p> <div id="mainContent"> <h1>contact us</h1><br /> <h2>Have questions? Ready to order?<br /> <span style="color:#b5a072">Call 704.333.1595 Mon-Fri 9am - 5pm EST</span></h2> <p id="contactText" class="text">It's not business, it's personal! For instant answers to many questions about ordering, shipping, and other good stuff, please check the <a href="shipping.php">useful q&a</a> page. Nonetheless, we'll always be happy to answer your questions by phone or through the form below. We look forward to hearing from you.</p><br /> <div id="contactFormContainer"> <form method="post" id="contactForm" action="<?php echo($_SERVER['PHP_SELF']); ?>" > <div id="formContainer"> <input type="hidden" name="submitted" value="true" /> <input type="hidden" name="formname" value="contact" /> <div class="formRow"> <div class="itemSet"> <p class="itemLabel">Name</p> <input tabindex="1" class="itemContent" type="text" name="guestName" value='<?php echo $_POST[Name]; ?>' /> </div> <div class="itemSet"> <p class="itemLabel">City & state</p> <input tabindex="2" class="itemContent" type="text" name="cityState" /> </div> <br class="clearMe" /> </div> <div class="formRow"> <div class="itemSet"> <p class="itemLabel">Email Address</p> <input tabindex="3" class="itemContent" type="text" name="emailAddress" /> </div> <div class="itemSet"> <p class="itemLabel">Phone & best local time to call</p> <input tabindex="4" class="itemContent" type="text" name="phone" /> </div> </div> <div class="formRow"> <div> <p class="itemLabel">Your question</p> <textarea tabindex="5" id="msgContent" type="text" name="msgContent">Please telephone us to submit an order</textarea> </div> </div> <div class="formRow"> <div style="position: relative;"> <div style="float: left; margin-right: 40px;"> <input tabindex="6" id="submitButton" type="submit" name="submit" value="Submit" /> </div> <div style="float: left; margin-top: -10px;"> <?php //echo($msg); ?> </div> <br style="clear: both;" /> <div style="clear: both; position: absolute; top: -350px; left: -217px; width: 180px;"> <?php echo($msg); echo($brisket); ?> </div> <br style="clear: both;" /> </div> </div> </div> <!-- End Form Container --> </form> </div> <!-- End Contact Form --> </div> </div><!-- End Content Area--> <div id="bottomBar"></div> <?php include("../common/footer.php"); ?> </div><!-- End Container --> </body> </html> CODE STOPS HERE===================================== Hello folks, well what I mean by temporary variables are variables like error messages or success messages that appear after a form has been submitted. I want to be able to kill these variables when the page is refreshed and return the page to its defualt state. For example, I'm making this simple page which is basically a form that ask users for some information, then upon submit, stores the in a database and prints a success message. If the form is filled out incorrectly or some form fields are left blank, then error messages are printed. What I really want is for these messages to disappear when the page is refreshed. My current model uses a second page to handle the form, and then upon succes or upon encountering an error, redirects to the form page, passing the error or success variables via the url to the form page where they are printed out. What can I do differently to achieve what I want (ie kill variables upon page refresh)? Below are the form page, and the page that handles the form respectively. Code: [Select] <form method="post" action="send_email.php"> <div id="contact_form"> <div align="left" class="green18">Contact Us</div> <br/> <br/> <label>Your Name:</label> <input class="texta" name ="name" size="20" maxlength="49"/> <br/> <br/> <div class ="error" style="position:relative;bottom:40px;left:128px" > <?php //Retrieve the encoded errors string from send_email.php page $errors_string=$_GET['errors_string']; //Explode the decoded errors string back to an array. $errors = explode(",", $errors_string); echo $errors[0];?> </div> <label>Your Company Name:</label> <input class="texta" name ="company" size="30" maxlength="66"/> <br/> <br/> <div class ="error" style="position:relative;bottom:40px;left:128px" > <?php //Retrieve the encoded errors string from send_email.php page $errors_string=$_GET['errors_string']; //Explode the decoded errors string back to an array. $errors = explode(",", $errors_string); echo $errors[1];?> </div> <label>Subject(Optional):</label> <input class="texta" name ="subject" size="20" maxlength="49"/> <br/> <br/> <label>Email:</label> <input class="texta" name ="email" size="20" maxlength="49"/> <br/> <br/> <div class ="error" style="position:relative;bottom:40px;left:128px" > <?php //Retrieve the encoded errors string from send_email.php page $errors_string=$_GET['errors_string']; //Explode the decoded errors string back to an array. $errors = explode(",", $errors_string); echo $errors[2];?> </div> <label>Message:</label> <textarea style="float:left" class="" name ="message" cols="40" rows="3"> </textarea> <br/> <br/> <div class ="error" style="position:relative;bottom:-19px;left:-260px" > <?php //Retrieve the encoded errors string from send_email.php page $errors_string=$_GET['errors_string']; //Explode the decoded errors string back to an array. $errors = explode(",", $errors_string); echo $errors[3];?> </div> <button class="button" type ="submit" name ="submit">Submit</button> <br/> <div id ="sent" > <?php //Retrieve the user id from send_email.php page $sent=$_GET['sent']; $send_msg = urldecode($sent); echo $send_msg; ?> </div> <!--closes sent--> </div> </form> Code: [Select] <?php //address error handling ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); if (isset($_POST['submit'])) { $errors = array(); // Connect to the database. require('config/config.php'); //Check for errors. //Check to make sure they entered their name and it's of the right format. if (eregi ("^([[:alpha:]]|-|')+$", $_POST['name'])) { $a = TRUE; } else { $a = FALSE; $errors[0] = '*Please enter a valid name.'; } //Check to make sure they entered their company name. if (!empty ( $_POST['company'])) { $b = TRUE; } else { $b = FALSE; $errors[1] = '*Please enter company name.'; } //Check to make sure email is valid. if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) { $c = TRUE; }else { $c = FALSE; $errors[2] = '*Please enter a valid email address.'; } //Check to make sure they entered their message. if (!empty ( $_POST['message'])) { $d = TRUE; } else { $d = FALSE; $errors[3] = '*Please enter your message.'; } //If no errors if (empty($errors)) { //Create variables for all the post values. $name = $_POST['name']; $company = $_POST['company']; $email = $_POST['email']; $message = $_POST['message']; $ip = $_SERVER[REMOTE_ADDR]; $date = (date("Y/m/d:G:i:s")); $timestamp = ( mktime(date(H), date(i), date(s), date(m) , date(d) , date(Y))); //Formulate the insert query. $query = "INSERT INTO emails ( email_id, name, company, email, message, ip, date,timestamp) VALUES ( 0, '$name','$company','email', '$message', '$ip' , '$date', '$timestamp' )"; $result = mysql_query($query) or die("Data could not be inserted into table because: " .mysql_error()); if (mysql_affected_rows() == 1) { // Display success message $sent_msg = "Your email has been sent. We will get back to you shortly."; $sent = urlencode($sent_msg); // Display contact page header("Location: contact_page.php?sent=$sent"); exit(); }else{die("There was a problem: " . mysql_error());} //Display error messages. } else {// if errors array is not empty //Confer the errors array into a string $errors_string = implode(",", $errors); //Encode the imploded string. $error_message = urlencode($errors_string); // Display page header("Location: contact_page.php?errors_string=$errors_string"); exit(); }//End of if there are errors. }//End of if submit. ?> Also, another problem I just noticed is that, the errors[3] variable isn't getting passed back to the form page. I don't know if it's because the url can only pass so much info to a second page. The page in question can be located he http://creativewizz.com/contact_page.php I am making a login system and I have done it before. ryanweekly.com is the site I am trying to put it on. Here is the script to the home page. Here is the code I am having a problem with: Code: [Select] <?php if (empty($username)) include ("loginbar.php"); if (!empty($username)) include ("logged.php"); ?> Code: [Select] <?PHP $username = $_SESSION['MM_Username']; ?> <?php require_once('Connections/ryanweeklyusers.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=$_POST['password']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "index.php"; $MM_redirectLoginFailed = "index.php?reg=loger"; $MM_redirecttoReferrer = false; mysql_select_db($database_ryanweeklyusers, $ryanweeklyusers); $LoginRS__query=sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $ryanweeklyusers) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();} //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } $ruser = $_REQUEST['Y2User-53201']; ?> <!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>Ryan Weekly</title> <style type="text/css"> body { background-color: #E3E5E2; } </style> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> </head> <style type="text/css"> <!-- body { font-size:12px; font-family:Verdana, Arial, Helvetica, sans-serif; } div#wrapper { width: 80%; background-color:#FFFFFF; margin-top: 50px; margin-bottom: 50px; margin-left: auto; margin-right: auto; padding: 0px; border: thin solid #000000; } div#header { padding: 15px; margin: 0px; text-align: center; } div#nav { width: 25%; padding: 10px; margin-top: 1px; float: left; border: thin solid #000000; } div#main { margin-left: 30%; margin-top: 1px; padding: 10px; border: thin solid #000000; } div#underhead { padding: 15px; margin: 0px; border-top: thin solid #000000; } { ul.nav a:hover, ul.nav a:active, ul.nav a:focus { /* this changes the background and text color for both mouse and keyboard navigators */ background: #6F7D94; color: #FFF; } .content ul, .content ol { padding: 0 15px 15px 40px; /* this padding mirrors the right padding in the headings and paragraph rule above. Padding was placed on the bottom for space between other elements on the lists and on the left to create the indention. These may be adjusted as you wish. */ } /* ~~ The navigation list styles (can be removed if you choose to use a premade flyout menu like Spry) ~~ */ ul.nav { list-style: none; /* this removes the list marker */ border-top: 1px solid #666; /* this creates the top border for the links - all others are placed using a bottom border on the LI */ margin-bottom: 15px; /* this creates the space between the navigation on the content below */ } ul.nav li { border-bottom: 1px solid #666; /* this creates the button separation */ } ul.nav a, ul.nav a:visited { /* grouping these selectors makes sure that your links retain their button look even after being visited */ padding: 5px 5px 5px 15px; display: block; /* this gives the link block properties causing it to fill the whole LI containing it. This causes the entire area to react to a mouse click. */ text-decoration: none; background: #8090AB; color: #000; } ul.nav a:hover, ul.nav a:active, ul.nav a:focus { /* this changes the background and text color for both mouse and keyboard navigators */ background: #6F7D94; color: #FFF; } /* ~~ The footer ~~ */ .footer { padding: 10px 0; background: #6F7D94; position: relative;/* this gives IE6 hasLayout to properly clear */ clear: both; /* this clear property forces the .container to understand where the columns end and contain them */ } /* ~~ miscellaneous float/clear classes ~~ */ .fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */ float: right; margin-left: 8px; } .fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */ float: left; margin-right: 8px; } .clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the #footer is removed or taken out of the #container */ clear:both; height:0; font-size: 1px; line-height: 0px; } --> </style> <body> <div align="Left"> <p><img src="indexp.png" width="728" height="90" /></p> </div> <div id="underhead"> <?php if (empty($username)) include ("loginbar.php"); if (!empty($username)) include ("logged.php"); ?> <?PHP $justreg = $_REQUEST['reg']; if ($justreg == yes) echo 'Thanks For Registering!'; if ($justreg == loger) echo 'There was an error while tring to log you in.'; if ($justreg == out) echo 'You were logged out!'; ?> </div> <?php include("menu.php"); ?> <div id="main"> <p>Welcome To Ryan Weekly! The all new and improved site!</p> <p>I have a song on itunes!</p> <p> <object width="400" height="160"> <param name="movie" value="http://widget.tunecore.com/swf/tc_run_h_v2.swf?widget_id=62316" /> <param name="allowFullScreen" value="true" /> <param name="allowscriptaccess" value="always" /> <embed src="http://widget.tunecore.com/swf/tc_run_h_v2.swf?widget_id=62316" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="400" height="160"></embed> </object> </p> </div> Ryan Weekly 2009 - 2011 (May 11, 2011 at 6:00PM Is our 3 Year anniversary!) <script type="text/javascript"> var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2"); </script> </body> </html> Hi i am wondering how i can redirect someone that's not logged in?
Hello all, This has probably been asked before but I couldn't find through search. And I'm pretty sure is not possible, but... Is there a way of displaying the windows logged on user? or get the name of the compter? as I know I can get the ip address. The reason I ask. Each user has their own network account but on occasion we need to log on a user as a generic account we have. And I want to check if it's this user accessing the page so different options etc can be displayed. I could use the computer name to check this as we log all activity. I could then query the log using the comp name to find logged on user. Unfortunately the log does not hold ip, which would seem obvious but it doesn't Many Thanks Hi guys, Im building a website for a company http://www.eminence-logistics.co.uk and the client wants a log in system which im having problems with. The registration system is all working fine. If you go to the website you can see where the login form is. Now when the user isn't logged in i need the form to show, but when the user IS logged in i would like a message replacing the form saying welcome, along with a log out button. How do i do this? Thankyou very much Enlighten Hi guys, Have a wierd scenario where my brain is simply refusing to think. I have small script which let's a user log in through a login screen. Thats ok. I can check whether the user is already logged in the same machine through sessions. My requirement is : I need to restrict the same username logging in from multiple computers at any one given time. In other words, a user can not use two machines to login at the same time. Can someone please suggest a method to solve this scenario. Your help is very much appreciated. Cheers Elabuwa Here is a link to screenshots of what is happening, because I'm crappy at describing things: http://imgur.com/a/ahvPA Of course I've messed the code up somewhere, but I can't for the life of me figure out where. I have a simple page for someone to enter text in a textbox to save in a database to display on another page. There are 10 textboxes on the page. I can enter text into any and all textboxes and it'll save the data in the database, EXCEPT if I enter text into the 2nd textbox. If there's anything in the 2nd textbox after I click submit, it will delete whatever was in the 2nd textbox and move all data in each textbox (except textbox 1, which stays in the same place) down one element. And it pushes the data in the final textbox off the page (presumably because there's no other textbox to accept its data). Here is the code to the two pages affected. Any help would be appreciated! Code: [Select] <?php // start the session session_start(); if (!session_is_registered($_SESSION['myusername'])) { header ('location:./login.php'); } $i=1; require_once('./dbconnect.php'); $sql="SELECT `event` FROM `events`"; $result=mysql_query($sql); mysql_close(); ?> <!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" xml:lang="en" lang="en"> <head> <title>Admin Portal</title> </head> <body> <form name="events" method="post" action="eventlogging.php"> <table width="800" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td> <table width="100%" border="0" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td colspan="3" bgcolor="#CCCCCC"> <strong><p><strong>Admin Portal</strong></p><p align="right"><small><a href="./logout.php">Logout</a></small> </td> </tr> <?php while ($i<11) { echo ' <tr align="center"> <td align="right" width="100">Event ' . $i . ' </td> <td width="800"> <textarea name=event' . $i . ' cols=40 rows=5>'; $row = mysql_fetch_array($result); if ($row) { $msg=$row[0]; echo $msg; }; $i++; echo '</textarea> </td> </tr> '; } ?> <tr> <td colspan="2"> <center><input type="submit" name="Submit" value="Submit" /></center> <input type="hidden" name="submitted" value="true" /> </td> </tr> </td> </tr> </table> </td> </tr> </table> </form> </body> </html> <?php $position = 1; $dbControl = 9; $event = array(); if (!empty($_POST['event1'])) { $event[] = $_POST['event1']; } if (!empty($_POST['event2'])) { $event[] = $_POST['event']; } if (!empty($_POST['event2'])) { $event[] = $_POST['event']; } if (!empty($_POST['event3'])) { $event[] = $_POST['event3']; } if (!empty($_POST['event4'])) { $event[] = $_POST['event4']; } if (!empty($_POST['event5'])) { $event[] = $_POST['event5']; } if (!empty($_POST['event6'])) { $event[] = $_POST['event6']; } if (!empty($_POST['event7'])) { $event[] = $_POST['event7']; } if (!empty($_POST['event8'])) { $event[] = $_POST['event8']; } if (!empty($_POST['event9'])) { $event[] = $_POST['event9']; } if (!empty($_POST['event10'])) { $event[] = $_POST['event10']; } include ('./dbconnect.php'); mysql_query("DELETE FROM `events`"); foreach ($event as $msg) { mysql_query("INSERT INTO `events` (`position`, `event`, `date`) VALUES ('$position', '$msg', curdate() )") or die(mysql_error()); $position++; } mysql_close(); $position=1; /* foreach ($event as $msg) { echo $position . '. ' . $msg . '<br />'; $position++; } */ header("location:./admin.php"); ?> It's been a while since I've needed to whip anything substantial up from scratch, so my scripting is a little (lot) fast and loose (weird/inefficient) here. I'm trying to mock up a script that's essentially a quiz/survey. There are a handful of topics, each with a few screens of yes/no questions. At the end, it returns a list of recommendations based on the answers gathered. The script is posting back to itself. Using print_r ($_SESSION), it seems like all of the post values for the first screen of questions are being assigned to the session array as expected. When the second screen of questions is answered, their values are assigned as well, but the values for the first set go away completely. This continues through subsequent screens, with the values from the previous screen present and all others before missing. I'd really appreciate a look at my code to see if you tell me the cause or error(s). Thanks! <?php session_start; include('_config.php'); // database connect $dbc = mysqli_connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname); // set to section 1, page 1 if no values are in _POST array if (($_SERVER['REQUEST_METHOD'] == 'GET') || (!isset($_POST['section']))) { $section = 1; $page = 1; } else { // something was posted, so...set those values in session variable foreach($_POST as $key => $data) { $_SESSION[$key] = $data; } // debug: display contents of the session array print_r ($_SESSION); // which section and page? $section = (int) $_POST['section']; $page = (int) $_POST['next']; } // check if last topic $query = "SELECT * FROM hw_topics"; $data = mysqli_query($dbc, $query); if ($section == mysqli_num_rows($data)) { $last_section = true; } else { $last_section = false; } // get current topic name and info $query = "SELECT topic, display_name, pages_in_topic FROM hw_topics WHERE topic_id = '$section'"; $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 1) { $row = mysqli_fetch_array($data); $topic_display_name = $row['display_name']; $pages_in_topic = $row['pages_in_topic']; } // test if last page in topic $topic_pages = $row['pages_in_topic']; if ($page == $topic_pages) { $last_page_in_section = true; } else { $last_page_in_section = false; } // set form action (set to this script or to recommendations when last section is complete if (($last_section == true) && ($last_page_in_section == true)) { $form_action = $CFG->reccomend; } else { $form_action = $_SERVER['PHP_SELF']; } // get current page headline $query = "SELECT page_headline FROM hw_pages WHERE topic_id = '$section' AND page_number = '$page'"; $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 1) { // The headline row was found so display the headline $row = mysqli_fetch_array($data); $page_headline = '<h2>' . $row['page_headline'] . '</h2>'; } // Grab the question data from the database to generate the list and form fields $query = "SELECT question_id, question_number, question_text FROM hw_questions WHERE topic_id = '$section' AND page_id = '$page' ORDER BY question_number"; $data = mysqli_query($dbc, $query); $questions = array(); while ($row = mysqli_fetch_array($data)) { array_push($questions, $row); } include($CFG->includesdir.'/header.php'); ?> <div id="head"> <h1>Assessment<?php if (isset($topic_display_name)) { echo ': <em>' . $topic_display_name . '</em>'; } ?></h1> <p class="paging">Page <?php echo $page; ?> of <?php echo $pages_in_topic; ?></p> </div><!-- #head --> <div id="content"> <p class="instr">Please complete this survey. We'll generate a list of recommendations and resources for your organization.</p> <div id="questions"> <?php echo $page_headline; ?> <form method="post" action="<?php echo $form_action; ?>"> <table border="0" cellpadding="0" cellspacing="0"> <thead> <tr> <td></td> <td class="qtext"></td> <td class="qanswer">yes</td> <td class="qanswer">no</td> <td class="pad"></td> </tr> </thead> <?php if ($questions) { // display question rows foreach ($questions as $question) { echo '<tr>'; echo '<td class="qnumber">' . $question['question_number'] . '.</td>'; echo '<td class="qtext"><p>...' . $question['question_text'] . '</p></td>'; echo '<td class="qanswer"><div class="radio" id="box-yes"><input type="radio" value="yes" name="qid_' . $question['question_id'] . '" id="qid_' . $question['question_id'] . '" class="radio" /></div></td>'; echo '<td class="qanswer"><div class="radio" id="box-no"><input type="radio" value="no" name="qid_' . $question['question_id'] . '" id="qid_' . $question['question_id'] . '" class="radio"'; $field_name = 'qid_' . $question['question_id']; if (isset($_SESSION[$field_name])) { echo ' checked="checked"'; } echo ' /></div></td>'; echo '<td class="pad"></td>'; echo '</tr>'; } } else { echo '<tr>'; echo '<td colspan="3" class="qtext"><p>No questions found in the database for this page.</p></td>'; echo '<td class="pad"></td>'; echo '</tr>'; } ?> </table> <ul id="controls"> <?php if ($last_page_in_section == true) { $section++; $page = 1; } else { $page++; } echo '<input type="hidden" value="' . $section . '" name="section" />'; echo '<input type="hidden" value="' . ($page) . '" name="next" />'; if (($last_section == true) && ($last_page_in_section == true)) { echo '<li><input type="submit" value="Submit Answers and Get Recommendations" name="submit" id="submit" /></li>'; } else { echo '<li><input type="submit" value="Next Page" name="submit" id="next" /></li>'; } ?> </ul><!-- #controls --> </form> </div><!-- #questions --> <?php mysqli_close($dbc); include($CFG->includesdir.'/footer.php'); ?> hello i am stuck and hoping you can help, i have created this function and its not working correctly, what i am trying to do is when someone is logged in they get this line of code echo "<a href=\"update-content.php?id=5\">Edit</a> | <a href=\"delete-content.php?id=5\">Delete</a>"; which is ok as i dont want that to work yet and if your not logged in you dont get it. i have added //show when logged in and show not logged in so you know which code i want it to load when at the moment its only loading the not logged in one even if you are. i have looked on google read up on php sites but cant figure out how to do it, so hoping you guys will tell me were i gone wrong and how to correct it, thanks again heres the code. function get_left() { if (isset($_GET['page'])) { $page = $_GET['page']; //Show Page not logged in $sql = "SELECT title,body FROM content WHERE page = '$page' AND location = 'left' AND disabled = 'no' ORDER BY id"; $res = mysql_query($sql) or die (mysql_error()); while($row = mysql_fetch_assoc($res)){ echo '<h1>' . $row['title'] . '</h1>'; echo '<p>' . $row['body'] . '</p>'; } } //show when logged in elseif ($_SESSION['username']&&(isset($_GET['page']))){ $sql = "SELECT title,body FROM content WHERE page = '$page' AND location = 'left' AND disabled = 'no' ORDER BY id"; $res = mysql_query($sql) or die (mysql_error()); while($row = mysql_fetch_assoc($res)){ echo '<h1>' . $row['title'] . '</h1>'; echo '<p>' . $row['body'] . '</p>'; echo "<a href=\"update-content.php?id=5\">Edit</a> | <a href=\"delete-content.php?id=5\">Delete</a>"; } } } What are the different ways you can keep a User "logged in"? From what I *vaguely* recall from a year or two ago when I read a whole hoard of PHP books, you commonly use cookies and sessions. But I'm asking this more from an OOP standpoint than a PHP standpoint. Let's say I have a User record in my database, and a User comes along and attempts to log in. In OOP terms, I would think you'd call some class to help log them in, and upon successfully logging in, you would "load" the User object into memory and set the "LoggedIn" field to "True". Then as long as that field was set in their object, they could surf all over the place and do things like change their account and buy things. Is that how you would do it in OOP? TomTees |