PHP - Keep Page Size On Submit
Hello i have a form on my page which submits on the same page but sometimes when i press submit and the page reloads the header padding comes out on the page so its actually split from the top of the screen and when its loaded it goes back, i have both margin and padding set to 0 for the body and header so dont know why this is happening, can someone help me out with this?
Similar TutorialsHi,
I am trying to make a page where the footer is loaded according to the screen size, so if someone is accessing the website via a tablet will be a footer, if it is from the computer, there will be another footer.
my problem is that although it is recognizing the windows width, it is not changing the footer accordingly.
this is my code:
$width = "<script>document.write(window.innerWidth);</script>"; if ($width < 900) { include("footer_mobile.php"); } else { include("footer.php"); }for some reason it is always loading the else footer even though the windows with changes. I added echo"$width" ; and the result of the variable was fine. does anyone know what the problem is cause it is driving me crazy? I can't figure out how to optimize my Zend framework performance. My query executes in 200ms but my page is taking almost 60 seconds to load. While checking the zend toolbar it shows that my page size is 14mb and I don't know why. The routes and options size is really large but I don't know what is causing this. Any ideas?
To see the full breakdown:
http://awesomescreen....com/0c73vewycc
hi i hv a form to submit on this url http://localhost/site/index.php?action=search and in my html <form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm"> // my code </form> // i also tried //http://localhost/site/index.php?action=search& // but did not helped now problem is i wants to go that URL so after submit it should look a like this as i am loading search page with action. http://localhost/site/index.php?action=search&searchstring=word but it keeps me redirecting to http://localhost/site/index.php?searchstring=word how can i make it work so it will goto this URL http://localhost/site/index.php?action=search&searchstring=word Thanks for help. How I am wondering how to add a redirect to a form with multiple buttons. All should redirect to same page Hello, Im new to website building. I have created a login system. The login system echoes some text when the username and password is correct. However, if correct i would like it to open another page on my site. Code: [Select] <form name="form1" method="post" action=""> <p>Username <label> <input type="text" name="username" id="username"> </label> Password <label> <input type="password" name="password" id="password"> </label> <input name="login" type="submit" id="login" value="Login"> <?php $username = $_POST ["username"]; $password = $_POST ["password"]; if ($username == "admin" && $password == "password"){ echo"Logged In";} ?> </p> </form> I am a novice and learnt this via youtube. However, can't find a tutorial for what i want. Thanks Hi there. When i press the submit button it shows me the blank page. Do u have any idea why? (i tried also to show me errors but it doesnt show even errors, although the display erorr works well) I want to send the user inputs and chosens to the database: (table form contains all the fields required (type, price, picture, gear,condition...etc)) here is the html page: Code: [Select] [m]<body> <div id="wrapper" class="container_12 clearfix"> <!-- Text Logo --> <h1 id="logo" class="grid_4"></h1> <!-- Navigation Menu --> <ul id="navigation" class="grid_8"> <li><a href="contact.php"><span class="meta">Get in touch</span><br />Contact Us</a></li> <li><a href="blog.php"><span class="meta">Latest news</span><br />Blog</a></li> <li><a href="portfolio.php"><span class="meta">Our latest work</span><br />Portfolio</a></li> <li><a href="about.php" class="current"><span class="meta">Who are we?</span><br />About</a></li> <li><a href="index.php"><span class="meta">Homepage</span><br />Home</a></li> </ul> <div class="hr grid_12 clearfix"> </div> <!-- Caption Line --> <h2 class="grid_12 caption">Complete the <span>Admin Form</span> </h2> <div class="hr grid_12 clearfix"> </div> <div> <div class="grid_12 caption"> <form action="adminFormSubmit.php" method="get" enctype="multipart/form-data" name="adminForm"> <table width="100%" border="0" align="center"> <tr> <th scope="row"><div align="right">Type</div></th> <td><div align="center"> <input type="text" name="type" id="type" /> </div></td> </tr> <tr> <th scope="row"><div align="right">Year</div></th> <td><div align="center"> <input type="text" name="year" id="year" /> </div></td> </tr> <tr> <th scope="row"><div align="right">Gear</div></th> <td><div align="center"> <select name="gear" id="gear"> <option value="M">Manual</option> <option value="A" selected="selected">Automatic</option> </select> </div></td> </tr> <tr> <th scope="row"><div align="right">Condition</div></th> <td><div align="center"> <select name="condition" id="condition"> <option value="N" selected="selected">New</option> <option value="U">Used</option> </select> </div></td> </tr> <tr> <th scope="row"><div align="right">Km's Past</div></th> <td><div align="center"> <input type="text" name="km" id="km" /> </div></td> </tr> <tr> <th scope="row"><div align="right">Price</div></th> <td><div align="center"> <input type="text" name="price" id="price" /> </div></td> </tr> <tr> <th scope="row"><div align="right">Picture</div></th> <td><div align="center"> <input type="file" name="picture" id="picture" /> </div></td> </tr> <tr> <th scope="row"> </th> <td><div align="center"> <input class="button" type="submit" name="adminFormSubmit" id="adminFormSubmit" value="Submit" /> </div></td> </tr> <tr> <th scope="row"><div align="right"></div></th> <td><p align="right"><a class="button" href="logout.php">Log out</a></p></td> </tr> </table> </form> </div> </div> <div class="hr grid_12 clearfix"> </div> <!-- Footer --> <p class="grid_12 footer clearfix"> <span class="float"><b>EpokaUniversity || All Rights Reserved © Copyright</b> || HarisKrasniqi, DiamantNeziri, HarisMemeti, KelmendTairi.</span> <a class="float right button" href="#">top</a> </p> </div><!--end wrapper--> </body>[/m] and here is the php code: Code: [Select] [m]<?php //check if the button is pressed if(isset($_POST['adminFormSubmit'])){ //Connect to database require_once('Connections/ecommerce_dbcon.php'); // Check to see if the type of file uploaded is a valid image type function is_valid_type($file) { // This is an array that holds all the valid image MIME types $valid_types = array("image/jpg", "image/jpeg", "image/bmp", "image/gif", "image/png"); if (in_array($file['type'], $valid_types)) return 1; return 0; } // This variable is the path to the image folder where all the images are going to be stored // Note that there is a trailing forward slash $TARGET_PATH = "adminform_images/"; // Get our POSTed variables $type = $_POST['type']; $year = $_POST['year']; $gear = $_POST['gear']; $condition = $_POST['condition']; $km = $_POST['km']; $price = $_POST['price']; $picture = $_FILES['picture']; // Sanitize our inputs $type = mysql_real_escape_string($type); $year = mysql_real_escape_string($year); $gear = mysql_real_escape_string($gear); $condition = mysql_real_escape_string($condition); $km = mysql_real_escape_string($km); $price = mysql_real_escape_string($price); $picture['name'] = mysql_real_escape_string($picture['name']); // Build our target path full string. This is where the file will be moved do // i.e. images/picture.jpg $TARGET_PATH .= $picture['name']; // Make sure all the fields from the form have inputs if ( $type == "" || $year == "" || $gear == "" || $condition == "" || $km == "" || $price == ""|| $picture['name'] == "" ) { echo "Te gjithe fushat duhet plotesuar. <a href=adminsection.php>Provo perseri</a>"; exit; } // Check to make sure that our file is actually an image // You check the file type instead of the extension because the extension can easily be faked if (!is_valid_type($picture)) { echo "Fotografite duhet te jene te formateve jpg, jpeg, bmp, gif, ose png. <a href=adminsection.php>Kthehu prapa</a>"; exit; } // Here we check to see if a file with that name already exists // You could get past filename problems by appending a timestamp to the filename and then continuing if (file_exists($TARGET_PATH)) { echo "Ju lutem nderroni emrin e fotos dhe provoni perseri. <a href=adminsection.php>Kthehu prapa</a>"; exit; } // Lets attempt to move the file from its temporary directory to its new home if (move_uploaded_file($picture['tmp_name'], $TARGET_PATH)) { // NOTE: This is where a lot of people make mistakes. // We are *not* putting the image into the database; we are putting a reference to the file's location on the server $sql = "INSERT INTO form (type, year, gear, condition, km, price, picture, date_added,) values ('$type', '$year', '$gear', '$condition', '$km', '$price', '" . $image['name'] . "', now(),)"; $result = mysql_query($sql) or die ("Futja e te dhenave ne databaze DESHTOI. <a href=adminsection.php>Provo perseri</a> "); echo "Shtimi i te dhenave u krye me SUKSES. Klikoni per te shkuar tek <a href=index.php>faqja kryesore</a>"; exit; } else { // A common cause of file moving failures is because of bad permissions on the directory attempting to be written to // Make sure you chmod the directory to be writeable echo "Shtimi i te dhenave NUK u krye me Sukses. Ju lutem provoni <a href=adminsection.php>perseri</a>"; exit; } } ?>[/m] I have the website he http://bossexclusive.com/babyauction/index.php , and http://bossexclusive.com/babyauction/thanks.php . When you press submit on the index.php, it takes you to thanks.php. then, after 5s, it takes you back to index.php. My question is: How could I make it so when I press submit, the box submits the form, but instead of redirecting to thanks.php, it displays the same thank you message on the side, but stays on index.php? If that didn't make sense, let me know. My html and php are below (HTML) Code: [Select] <!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>Baby Auction | Discounted Premium Brand Baby Products</title> <link rel="stylesheet" type="text/css" href="styles.css"/> </head> <body> <div id="main"> <div id="contact"> <h1>Sign up to recieve Auction notifications</h1> <form action="emailer.php" method="post"> <input type="text" name="email" id="email" placeholder="yourname@email.com" /> <input type="image" name="submit" src="images/submit.jpg" width="146px" height="20px" value="Submit"> </form> </div> </div> <div class="copyright"> <?php include 'footer.php'; ?> </div> </body> </html> and emailer.php: Code: [Select] <?php $email = trim(strip_tags($_POST['email'])); $subject = "Contact form submitted!"; $to = 'BlankingOutMyEmail@gmail.com'; $body = <<<HTML $message HTML; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; mail($to, $subject, $body, $headers); header('Location: thanks.php'); ?> Hello, I'm having trouble figured out how to do this... Basically I want update.php to run after the user hits the 'update' button, and after update.php runs (which will take about 60 seconds) I want the index.php to reload. How can this be done? thanks! <!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>Server List</title> </head> <body> <?php $mlink = @mysql_connect("localhost","user","pass"); mysql_select_db("dbname", $mlink); $result = mysql_query("SELECT * FROM ServerList"); while($row = mysql_fetch_array($result)){ echo $row['HostName']. " - ". $row['UsedSlots']. " / ". $row['MaxSlots']; echo "<br />"; } ?> <br/> <br/> <form action="update.php" method="post"> <button type="submit">update</button> </form> </center> </body> </html> I have two pages. one is insert_events.php and the other is veiw_events. In insert_events i have a form which have a submit button. I want when i click on the submit button, it redirects me to the view_events.php page showing the events. Any idea about this problem will be appreciated. Thanks Hi All, Is there any way that PHP can detect if a page has been refreshed? Basically I have a form that when submitted, inserts a row in to a database, but I am finding that when I refresh the page, it repeats the insert statement. Any ideas? Thanks Matt Hi everyone, as the title stated, I would like to know how I could submit a form in one page(cart) and unset a session variable on other page.
Right now my form is setting a variable within the page back to 0, however I would like the form to unset the session variable from other page as well.
The issue with my code is that every time I attempt to clear out all items, my code can empty out the cart. But whenever I close and reopen the cart, the same content will show up again. So I need to unset the session variable.
Please let me know what should I do in order to solve the problem and I greatly appreciate your help.
My code is currently looking like this:
cart.php
if(!empty($_GET['aID'])) { $aID = $_GET['aID']; echo $aID; if(isset($_POST['removeAll'])) { $aID = "0"; } $cartSQL = "SELECT * from article where aID in ($aID)"; echo "cart sql :$cartSQL"; $cartQuery = mysqli_query($dbc, $cartSQL) or die (mysqli_error($dbc)); while($row = mysqli_fetch_array($cartQuery, MYSQLI_BOTH)) { $aTitle[] = $row[ 'name' ]; } } <form action = "" method = "POST"> <td style = "width = 200px"><input type="submit" value="Empty cart" name="removeAll"></td> </form>And this is the session variable from other page where I would like it to be unset upon submitting the form. if(!empty($cartSubmit)) $_SESSION["cartSubmit"] = $cartSubmit; else $cart = $_SESSION["cartSubmit"]; <a href="javascript:popup('cart.php?aID=<?php if(empty($cartSubmit)) echo "$cart"; else echo "$cartSubmit";?>')">Cart</a> I have two pages one is db.php and another is form.php. In form.php i have created a form which contains different fields and a submit button. But i want to write the queries in db.php. And when i click on the submit button the insert query in db.php should be executed and insert data in database but the focus remains on form.php. How can i do this??? Any Idea? Hi Guys, I am fairly new to PHP, and I recently changed my whole site to use PHP sessions, which worked fine. Then I added PHP parts in my pages that display different menu choices depending on if a PHP session exists. This also works fine, until I found that any HTML/PHP pages that have form/submits no longer work, and I get kicked back to the index.php After slow backtracking, I removed new parts, and found the forms started working again if I removed the PHP part that chooses which JavaScript file to reference, as follows from contact.php <?php if (isset($_SESSION['SESS_MEMBER_ID'])){ echo "<script language=\"JavaScript\" type=\"text/javascript\" src=\"menu_horz.js\"></script>"; } else {echo "<script language=\"JavaScript\" type=\"text/javascript\" src=\"log_menu_horz.js\"></script>"; } ?> I tried changing the echo ".." to use single quotes ' ' instead, but then it doesn't work at all then with a form or no form on the page. I assume I am doing something wrong, but I can't find any resources that give me a definitive way of referencing Javascript files. What freaked me out was only the ones with forms were an issue. I am using <?php session_start(); ?> at the beginning of every page (before any output). Other PHP code on the page is working fine. Only the above part seems to be the problem, and works too, as long as I don't submit a form. - Could it be more weirder :-) - I tried also to find a workaround, but it would mean having PHP inside my JavaScript file, but I am not sure it would work, since JS is client side, and PHP server... Essentially, I just want to run certain JS menus depending if the person is logged in or not. - Example contact.php attached Any ideas of what the problem might be with the code above? Will be grateful for any help you can give. Regards D This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=331067.0 I am creating a user inbox system. I am retrieving all the unread messages. Each message row contains a "reply" form. So say I have 10 messages showing on a single page. That's 10 forms. What I would like to know is how can I submit any one of the 10 forms and not have it affect the remaining 9 forms? Here is the basic code. if(isset($_POST['submit'])) { $post_message = trim($_POST['message']); $errors = array(); $db->beginTransaction(); if(empty($post_message)) { $errors[] = 'The message field can not be empty!'; } if(empty($errors)) { $db->commit(); echo 'success'; } else { $db->rollBack(); } } <form action="" method="post"> <fieldset> <textarea name="message" maxlength="10000" placeholder="What would you like to say?"></textarea> </fieldset> <fieldset> <input type="submit" name="submit" value="Submit" /> </fieldset> </form>
Alright, so I play a browser game called Politics and War. I run an alliance that has 74 members. In that alliance we offer a bank service for all our members, but I - being the leader - am the only one who can access the bank. I have been building a site that works with the game API to gather data for members and create a dashboard. One of the features I am trying to build is allowing them to withdraw from their account instantly.
So, what I need: To be able to submit a POST request to login to the site (specifically on this page --> https://politicsandwar.com/login) with my username and password, but then I need to keep the session active and navigate to a different page (the alliance bank page). On that page I first need to scrape a value from a hidden input (token) and then I need to submit a POST request to this same page while still being logged in.
I am not asking someone to do it for me, but rather someone to help me know how to go about this. I have never submitted post requests with PHP, but I have used PHP cURL in the past. I also have made POST requests with JS, but never PHP.
Thank you so much for anyone that is able to help! Hi all !
I wish to post the value of an auto submit dropdown value to another page, be redirected to that page, and use it on that page. I am unable to achieve this in php and so I tried as :-follows:-
dropdown.php
<form method="post" action = dropdownaction.php> <select name="myselect" onchange="this.form.submit();"> <option>blue</option> <option>red</option> </select> </form>and now I need the equivalent of dropdownaction.php <?php if(isset($_POST(['myselect']))) echo " I am selected".$_POST['myselect']; ?>Please can someone tell me how I may retrieve the value of 'myselect' in the dropdownaction.php after being redirected to it. Thanks loads. could someone help in how to resize a uploaded image size, say if someone is uploading a 1mb photo to my server, i wish for it to become 100kb and also resize its width and height? here is my code Code: [Select] //////////////////////////////////////uploader else if($action=="uploader") { echo "Upload your picture and copy the link <br/>after uploading to user it at gallery.<br/><br/>"; echo "<form method=\"post\" enctype=\"multipart/form-data\" action=\"index.php?action=uploaded&sid=$sid\">"; echo "Choose Pictu <br />"; echo "<input name=\"uploaded\" type=\"file\" /><br /><br />"; echo "<input type=\"submit\" value=\"Upload\" />"; echo "</form><br/>"; echo "<p align=\"center\">"; echo "<a href=\"index.php?action=main&sid=$sid\">Home</a>"; echo "</p>"; } //////////////////////////////////////uploader else if($action=="uploaded") { $blacklist = array(".php", ".php.jpg", ".php.jpeg", ".php.gif", ".php.png", ".phtml", ".php3", ".php4"); foreach ($blacklist as $item) { if(preg_match("/$item\$/i", $_FILES['uploaded']['name'])) { echo "<p align=\"center\">"; echo "Oops sorry we do not allow those files.<br/>"; echo "<a href=\"index.php?action=main&sid=$sid\">Home</a>"; echo "</p>"; exit; } } $target = "../images/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; if (file_exists("../images/" . $_FILES["uploaded"]["name"])) { echo "<p align=\"center\">"; echo $_FILES["file"]["name"] . "Oops file name already exists<br/> kindly rename your picture and upload again. <br/>"; echo "<a href=\"index.php?action=main&sid=$sid\">Home</a>"; echo "</p>"; }else{ //This is our size condition if ($uploaded_size > 25600){ echo "Your file is too large. We have a 25kb limit.<br/>"; $ok=0; } $types = array('image/jpeg', 'image/gif', 'image/png'); if (in_array($_FILES['uploaded']['type'], $types)) { // file is okay continue } else { $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0){ echo "<p align=\"center\">"; Echo "Sorry your file was not uploaded.<br/> It may be the wrong filetype. <br/>We only allow JPG, GIF, and PNG filetypes.<br/>"; echo "<a href=\"index.php?action=main&sid=$sid\">Home</a>"; echo "</p>"; } //If everything is ok we try to upload it else{ if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)){ echo "<p align=\"center\">"; echo "The file ". basename( $_FILES['uploadedfile']['name']). " Picture uploaded successfully.<br/><br/><b>$target <br/>"; echo "<a href=\"index.php?action=main&sid=$sid\">Home</a>"; echo "</p>"; } else{ echo "<p align=\"center\">"; echo "Sorry, there was a problem uploading your file.<br/>"; echo "<a href=\"index.php?action=main&sid=$sid\">Home</a>"; echo "</p>"; } } } } This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=326913.0 Say I have an "Entries" table. I want to submit same multiple entries using a form submission. And If I have other queries submitted in the same form, I want those quarries to be submitted only once. Is that possible to do? Here's my code. if(isset($_POST['submit'])) { $entries = 10; $id = 55; $name = 'Smith'; $insert = $db->prepare("INSERT INTO entries(id, name) VALUES(:id, :name)"); $insert->bindParam(':id', $id); $insert->bindParam(':name', $name); $result_insert = $insert->execute(); if($result_insert == false) { echo 'Fail'; } else { echo 'Success'; } } ?> <form action="" method="post"> <input type="submit" name="submit" value="SUBMIT" /> </form> Edited January 13, 2019 by imgrooot |