PHP - Moved: Page Reloads It Will Be At The Same Scroll Position.
This topic has been moved to JavaScript Help.
http://www.phpfreaks.com/forums/index.php?topic=349588.0 Similar TutorialsThis topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=345046.0 Hi, I have been trying to get the below code to work but without luck for the past couple of days. Can anyone help point out where i am going wrong. I have a webpage that has several buttons which will eventually let users search for data stored in different tables of a postgresql database ( i have simplified the code here to just two buttons). When the user clicks the Search for hostname button a form is displayed letting them type in their search criteria. Upon clicking the submit button i am able to access the users search strings with no problem but i cannot get the original search form to display above the search results additonaly including the users original search strings. Any help on this would be much appreciated as i am pulling my hair out, as you can probably guess i am very new to PHP/HTML My code is <? session_start(); ?> <form method="POST" action="<? echo $_SERVER['PHP_SELF'];?>"> <center> <button type="submit" id="green_button" name="searchhostname">Search for Hostname</button> <button type="submit" id="green_button" name="searchipaddress">Search for IP address</button> </center> </form> </body> <? // If user clicks the search hostname button display the additonal search form if ($_POST['searchhostname']) { echo "Search for Hostnames and IP Addresses:<br><br>"; echo "<form method='POST' action='".$_SERVER['PHP_SELF']."'>"; echo "Hostname: <input type='text' name='hostname' size='16' value='".$_POST['hostname']."'/>"; echo "<br>"; echo "Operating System: <input type='text' name='ostype' size='16' value='".$_POST['ostype']."'/>"; echo "<br>"; echo "<input type='submit' id='green_button' value='Search' name='runsearch'><br><br>"; echo"</form>"; } // If user has entered criteria to search on run the search but alos display the original search form above // and any data the user has entered before displaying results if ($_POST['runsearch']) { //In reality this is where the users search data will be compared to a postresql database.... echo "You want to search for hostname: ".$_POST['hostname']."<br>"; echo "You want to search for operating system: ".$_POST['ostype']."<br>"; } ?> Hi all, Not sure if this is a browser feature kind of thing, or if it can be done with a script. I'm looking at my page: www.mysite.com/index.php?start=0 I scroll to the bottom of the page with the vertical scroll bar, and then click the pagation link to start on page 2, record #50: www.mysite.com/index.php?start=50 Of course, the vertical scroll bar jumps back to the it jumps to the top of my page. Is there a way to make it remember that the scroll bar was at the bottom (or in the middle)? Thanks. After inputing my email and password and clicking submit, the echo in Verify_User (in bold) doesn't show up, nor does it load the logged in form of the log in bar. If I reload the page or press submit again (even without entering any information), everything works. At first I though I might just be outputting before getting my input on the reload, but all info is obtained at the top. I also thought it might be $logoff, but it doesn't tell me "You logged off!", while still setting $logoff to true by the end in order to output the login menu. Therefore, it get's passed if($Logoff) but doesn't make it to Verify_user, so for some reason $L_Email and $L_Password aren't set after the first refresh. I'm a newbie so any help, related to the problem or not, would be greatly appreciated. P.S. The logoff button works the first time. Code: [Select] <?php $L_Email = $_POST['l_email']; $L_Password = $_POST['l_password']; $Logoff = $_POST['logoff']; //if the page was requested with an effort to logoff if ($Logoff) { //setcookie("session_email", "", time()-3600); setcookie("session_password", "", time()-3600); } //if logging in, Email and password are already set, make them cookies else if($L_Email && $L_Password) { setcookie("session_email", $L_Email, 0); setcookie("session_password", $L_Password, 0); } $L_Email = get_email_cookie(); $L_Password = get_password_cookie(); $logbar_html = ""; if($Logoff) { $logbar_html = $logbar_html . "You logged off!<br>"; } else { //if there was a cookie or apt input if ($L_Email && $L_Password) { //if logged on if(verify_user($L_Email, $L_Password)) { $logbar_html = $logbar_html . "Hello $L_Email!<br>"; $logbar_html = $logbar_html . "<form action='index.php?at=". $_GET['at'] . "' method='post'> <input name='logoff' type='submit' value='logoff'> </form>"; $logbar_html = $logbar_html . "<a href='index.php?at=edit_account'><text size=1>Edit your account!</text></a><br>"; if ($L_Email == "scott.jaromin@gmail.com") { echo "<a href='index.php?at=admin'>Admin</a>"; } } else { $logbar_html = $logbar_html . "Login Failed<br>"; $Logoff=true; $L_Password=NULL; } } //if this, you are definitely logged off else { $Logoff = true; } } //if you are logged off if($Logoff) { $logbar_html = $logbar_html . "<a href='index.php?at=register'><text size='0'>Register!</text></a><br> <form action='index.php?at=". $_GET['at'] . "' method='post'> Email: <input name='l_email' type='text' value='$L_Email'/><br> Password: <input name='l_password' type='password' /> <br> <input type='submit' /> </form> "; } function get_email_cookie() { $email_cookie = ""; if(isset($_COOKIE["session_email"])) { $email_cookie = $_COOKIE["session_email"]; } return $email_cookie; } function get_password_cookie() { $password_cookie = ""; if(isset($_COOKIE["session_password"])) { $password_cookie = $_COOKIE["session_password"]; } return $password_cookie; } function verify_user($email_check, $pass_check) { echo "verifying $email_check $pass_check"; $con = mysql_connect("my", "info", "only"); if (!$con) { die("Could not connect: " . mysql_error()); } mysql_select_db("begood4u_barter", $con); if(!$email_check || !$pass_check) { return false; } $result = mysql_query("SELECT Password FROM Members WHERE Email='$email_check'"); $real_pass = ""; if($row = mysql_fetch_array($result)) { $real_pass = $row['Password']; } else { echo "$result"; } echo " real pass: $real_pass"; mysql_close($con); return($pass_check == $real_pass); } ?> This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=357646.0 Is there a code I can put with each of these errors so that, on error, the page reloads back to the bottom of the page? When you enter the wrong info, the page already reloads but it reloads to the top of the page. People who didnt correctly information into the webpage may not see that they're receiving an error if it doesnt scroll back down. I attempted to put the error at the to of the page but I couldnt find a good spot. I thought about doing an error message box but I'm not sure thats the best method Anyway heres the code, thanks a lot. <?php if ($_POST['send']) { $errors = array(); if ($_POST['captcha'] != $_SESSION['captchacode']) { $errors[] = "You didn't enter the correct letters!"; <-------------ID LIKE TO PUT A CODE HERE AND } if (empty($_POST['email'])) { $errors[] = "Please enter an e-mail address"; <-----------------HERE TO MAKE THE PAGE GO TO THE BOTTOM WHEN IT REFRESHED (IT REFRESHES UPON EVERY IMPROPERLY FILLED OUT FORM } else if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) { $errors[] = 'Please enter a VALID e-mail address'; } if (!count($errors)) { // IMPORTANT: If you don't call this the // user will keep getting the SAME code! captchaDone(); guys i have a submit button that if(isset($_POST['sub_diplo'])) { $_SESSION['tmp']=$_SESSION['tmp']." counts "; } but tthe button is at the end of the page so when i press the button the page reloads and gose to start! exept that my code working! so is any way to move page to first location?? thanks I have finally gotten my registration form to work on my website but i have another question! When for example someone registers at my website and type in the wrong email address, i've set php to give out an error message like "Please enter a valid email address". But that message shows up at the verry top-left corner of my page and makes some objekts move around on my page and you can't click in the <input> fields anymore . How could i make those error messages show up above my registration form at the top of my site and maybe style them with a border and maybe make the text red and so that it doesnt change anything on my page? could i use css for that somehow or what? This is how i show the error messages right now: public function show_errors() { echo "<h3>Errors</h3>"; foreach($this->errors as $key=>$value) echo $value."<br>"; } public function valid_data() { if($this->user_exists()) $this->errors[] = 'Username already taken, choose another one!'; if(empty($this->username)) $this->errors[] = 'Please enter a valid username!'; if(empty($this->first_name)) Dear forum, I`m always trying hard, but after 5 hours I really need some help in php coding. My problem deals with my checkout page for woocommerce. At the moment, my legal terms are above the total-order-table where u can find the booked product, order-subtotal, order-total and tex-total. But I need to display the legal terms under my total-order table. I need the terms directly above the "Buy now" button. Do you guys know which file to modify ? I tried everything. Nothing worked for me. You will find a picture in this post. There you can see my problem. Would be pretty nice if you can give me some information. Kind regards,
This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=323045.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=343063.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=359321.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=358157.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=321550.0 This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=342818.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=347332.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=331209.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=320495.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=315372.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=321494.0 |