PHP - Moved: How To Disappear A Checkbos After It Is Checked
This topic has been moved to JavaScript Help.
http://www.phpfreaks.com/forums/index.php?topic=358408.0 Similar TutorialsThis 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=318750.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=349419.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=349419.0 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; } 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. 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? 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 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'); ?> Hi guys, I wonder if any if you could help me: I have created a login page with "remember me" function... The page will redirect either to Admin Page or User Page depends their 'level'. But when I logged in as Admin and checked the box "remember me" and close all the browser to see IF the "remember me" work. When I open a new browser - and go to the index page - it is okay, I can view the page.... but it redirect me to the USER page NOT Admin page. Does anyone know why this happens? i am having issues checking which value is checked in a form. here is my code for it: Code: [Select] <input type="radio" name="accountActivation" id="no" value="no" checked=" <? if (isset($register_errors)) { if (($_POST['accountActivation']) == "no") { echo "checked"; } } ?> " /> when i first open the page, no is checked. why is this, when there should be no errors, and the radio should not even be checked in the first place? Hello all, The following script is used to query an array. (www.example.com/test.php?lev[]=MS&lev[]=College) Currently, it echos the values queried and simply lists them (echo "$lev (br />\n"). Is it possible to echo those values by keeping the checkbox in question checked instead? Code: [Select] <?php echo "<b>Levels <br /> />"; if(!empty($_GET['lev'])) foreach($_GET['lev'] as $lev){ echo "$lev <br />\n"; } ?> <form /> <input type="checkbox" name="lev[]" value="PreK" /><font class="sm">PreK</font> <input type="checkbox" name="lev[]" value="Elem" /><font class="sm">Elem</font> <input type="checkbox" name="lev[]" value="MS" /><font class="sm">MS</font> <input type="checkbox" name="lev[]" value="HS" /><font class="sm">HS</font> <input type="checkbox" name="lev[]" value="College" /><font class="sm">College</font> <input type="submit" value=" ..:: Submit ::.. " /> Thank you. ~Wayne How to write the code to get the count of the word "CHECKED" from a row? I tried this and it's not working. Please help. $query = mysql_query("SELECT field1, field2, field3, COUNT(CHECKED) as counter FROM db1 WHERE row_name = 'science'"); while($line = mysql_fetch_array($query)) { echo $query['counter']; } What is the best way using php to see if a checkbox is checked or not. I see so many different options out there googling, that I am interested knowing the most robust method. Thanks Hi: How do I check to see if a checkbox has not been checked? Would the same rules apply to a radiobutton? This is what I have: Code: [Select] <input name="status[1]" id="approved" value="<?php echo $_POST['approved'] ?>" type="checkbox" /> <label for="approved">Approved</label> Code: [Select] if (isset($_POST['status[1]'])): $errMsg['status[1]'] = "Must select a status."; endif; I tested it out, but it just prints the error message even if I have checked it hi all I have 3 checkboxes whose values are getting stored in the database with a comma separator. Code: [Select] <input name="color[]" type="checkbox" value="red" id="red" />red <input name="color[]" type="checkbox" value="blue" id="blue" />blue <input name="color[]" type="checkbox" value="green" id="green" />green values getting stored with comma separator Code: [Select] red, blue, green now i want to show the checkboxes as "checked" to show the customer as which colors they chose lasttime when they submitted the form. How can i make it possible ? If it is possible without the comma separator then i can remove the comma. vineet I am using the following piece of code to open a new window when a checkbox is checked... <INPUT type="checkbox" name="name" value="YES" onClick="window.open('/somepage.php?do=something&id=<?php echo $SOMEID["id"] ?>','','width=600,height=350,left=100,top=100,screenX=100,screenY=100')"> The page opens ok when the checkbox is ticked (checked). PROBLEM: The page opens again if the checkbox is un-ticked (un-checked). I just want to open the page if the checkbox is ticked only but not sure how to do this? OTHER INFO: Seperate checkboxes are dynamically created on the page for each id=<?php echo $SOMEID["id"] ?> |