PHP - Empty Entry On Reload Page
Hello dear friends,
I've very annoying problem my website is for child drawing (draw.php) after child do drawing will click on submit (form) by sending it to another page (thanks.php) | | | | data will be submitted to database and gives message saying ( thank you for ...blah blah blah) here is the problem if he refresh the page , it will also add entry to the database so imagine if someone did many many refresh, i will get many many empty entry into database how to stop this ? here is simple code based on this problem Code: [Select] <form name="frm" method="post" action="thanks.php"> <input type="text" name="name" id="name" value=""> <input type="text" name="email" id="email" value=""> <button type="submit">Submit</button> </form> and the (thanks.php) file code *assume we have connection to db Code: [Select] $sql = "INSERT INTO $table (name, email) VALUES ('$name', '$email')"; mysql_query($sql, $conn) or die(mysql_error()); echo "Thank you kid..nice drawing"; now my problem if (thanks.php) got refreshed it will also will add empty entry to database can anyone please help me how to stop it. Similar TutorialsHello there,
I would be really grateful if someone could advice please, how do I find this pesky entry in the 'db' table? This is what it says,
"Found an entry in the 'db' table with empty database name; Skipped." MySQL version is 5.5.40
I am pretty much stuck on it. Does it mean the table's name is db? Plus, I am not sure I understand the wording of it too. The empty database name cannot exist by default as it won't allow you to create a database without a name in the first place. I do not even know how and where to begin to look for it because honestly speaking I do not quite understand the phrase itself, because it does not make much sense to me. I would really highly appreciate it if someone could explain and suggest how do I find the... "whatever it says" :-) and to fix it. Many thanks in advance!
P.S. I know this warning may easily and safely be ignored as it is of minor inconvenience and not that important the more so as MySQL is working fine but my curiosity is just running wild for two reasons: 1. I do not really understand what this warning message is trying to tell me and 2. How do I find and adjust it to turn off the warning.
Simple regular things as running myisamchk -r *.MYI on where MySQL is did not help as this warning is actually out of scope of what myisamchk can fix.
And yes, I've Googled it long enough but couldn't seem to come up with anything reasonable solutions.
Thankful for any suggestions / pointers / assistance / comments at all.
Edited by Klaipedaville, 29 October 2014 - 06:17 AM. hello guys, i have a question, in some php files i have in the start <? ob_start(); ?> <?php session_start(); ........ ..... ...... if(isset($_POST['sub_1'])) { $_SESSION['address_tmp']=$_SESSION['address_tmp']." oK "; header("location:some_other_page.php#jumpselection"); } if(isset($_POST['sub_2'])) { $_SESSION['address2_tmp']=$_SESSION['address2_tmp']." hello "; header("location:thispage.php#jumpselection"); } ?> <body> <form method="post" action=""> <input type="Submit" name="sub_1" value="action1"style="height:3.9em; width:16.5em; font-size:95%;"> </form> </body> <body> <form method="post" action=""> <input type="Submit" name="sub_2" value="action2"style="height:3.9em; width:16.5em; font-size:95%;"> </form> </body> <? ob_end_flush(); ?> but every page have 10-15 buttons every button in the end reloads the same page with header("location:thispage.php#jumpselection"); or cals another page with header("location:some_other_page.php#jumpselection"); this works but i notise some lag on the bowser afrer while.. I would like the page orderform.php to reload or refresh to normal after I click this link: this is what i have and this link is on a different page though... if($myError==true) echo "<br /><br />Click here to <a href='orderform.php?nocache='.time().'>go back...</a>"; else header("location: orderform.php"); I have an html table that is being populated with links from a specific directory.. I would like the user to be able to click the link and if its a file they will download the file. If its a directory, I woudl like to reload the current page but this time show the contents of the directory. My main issue is that I have a session variable called 'workingdirectory' that I need to update before I reload the page. I have tried setting it and then calling Location('page.php') but I get the 'cannot change header information' error. I realized I was getting this because I had begun to call HTML code before the PHP was finished. Is there a way to just simply update the session variable, and then make the page reload when the user clicks on a link? The Script:
<h1>Do Add a Message to the MySQL Database</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <textarea name="message"></textarea> <br/> <input type="submit" name="submit"/> </form> <?php // The Connection to the Database // Taken Out ?> <?php // To insert the text data into the MySQL database. if(isset($_POST['submit'])){ $tqs = "INSERT INTO messages (`message`) VALUES ('{$_POST['message']}')"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); } ?> <?php // To select the text data from the MySQL database. $tqs = "SELECT * FROM messages"; $tqr = mysqli_query($dbc, $tqs); // To print out the text data inside of table on the page. echo "<h1>This Is Where the Messages Gets Printed on Screen</h1>"; echo "<table><tr><td>ID</td><td>The Message</td></tr>"; while($row = mysqli_fetch_assoc($tqr)){ echo "<tr><td>" . $row['id'] . "</td><td>" . $row['message'] . "</td></tr>"; } echo "</table>"; ?>1. When I have added text with the form to the MySQL database... 2. ... and I have clicked on "page reload" in Firefox to reload the page... 3. ... then the before submitted text gets submitted again to the MySQL database. So basically, add text with the form to the MySQL database, reload the page in Firefox, and the before added text will get submitted to the MySQL database again. My Question Is: What is the proper way to avoid this? Edited by glassfish, 06 October 2014 - 10:18 AM. Hello, I am having issues with getting cookies to function how i'd like them to. My goal is to be able to capture a cookie value from the url if a user comes to my site via something like adwords. An example URL they could come to is http://www.mysite.com?kw=hello I am trying to capture the word 'hello' and tie it to that visitor regardless of where they go on the site. I need to use that value to pass through if they complete a form on my site so that i can track the keyword source. I have included the following as the first line of code on every page of my site: Code: [Select] $kw = $_GET["kw"]; setcookie('kw',$kw); Then, if i go to this url: http://www.mysite.com?kw=hello and then later go to a url like this: http://www.mysite.com/page1.html, i am able to echo out the cookie on page1.html using the following code which is contained in page1.html: Code: [Select] echo $_COOKIE["kw"]; The problem is, if i then refresh page1.html i can no longer echo out the cookie--it disappears. I need the cookie to stay with the user no matter what page they are on within the site and not matter how many different pages they visit. I hope i am explaining myself in a way someone can understand. Perhaps cookies aren't the best way? Should i use sessions instead? Thanks in advance for your help This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=346243.0 Hi All, I was wondering if there is any way that a PHP page can update itself when a row in a DB is added or updated? I am trying to get a feed up and running and want it to update when a row is updated/inserted. Thanks Matt Below is my code... it writes to the SQL database but does not show on the HTML page. Any advice? Code: [Select] <?php $query = mysql_query("SELECT * FROM `entries`"); $query = mysql_query("SELECT *, UNIX_TIMESTAMP(`date`) as date FROM `entries` ORDER BY `date` DESC LIMIT"); ?> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td valign="top"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td valign="top" class="entrysmall" align="right">Posted on: <?php echo date("d/m/y g:i a", $row['date']); ?></td> </tr> <tr> <td valign="top"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td valign="top" style="padding-right: 10px;"><span class="entrytitle">Name:</span></td> <td valign="bottom" width="100%"><?php echo htmlspecialchars(stripslashes($row['name'])); ?></td> </tr> <tr> <td valign="top" style="padding-right: 10px;" nowrap="nowrap"><span class="entrytitle">E-Mail:</span></td> <td valign="bottom" width="100%"><?php $email = explode('@',stripslashes($row['email'])); echo $email[0].' *at* '.$email[1]; ?></td> </tr> <td valign="top" style="padding-right: 10px;"><span class="entrytitle">Hometown:</span></td> <td valign="bottom" width="100%"><?php echo htmlspecialchars(stripslashes($row['hometown'])); ?></td> <tr> <td valign="top" style="padding: 5px 10px 0px 0px;" colspan="2"><span class="entrytitle">Message:</span></td> </tr> <tr> <td valign="top" style="padding-right: 10px;" colspan="2"><?php echo smilies(htmlspecialchars(stripslashes($row['message']))); ?></td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td valign="top" height="10"></td> </tr> </table> Whenever I see a PHP website (and given ftp access) I often struggle to find the entry page. Most I see don't have index.php in the public_html directory - or that isn't the main entry page. Htaccess and adding Wordpress, shopping carts etc. also messes around with which file is the entry page. Is there a quick checklist of what a simpleton should do to find the entry page? E.g. (1) Check .htaccess................ etc. Alright, wasn't quite sure how to summarize this in the title, but I want to: Check if a user status is "active" or not based on the UserName input. I have a table witch holds: Code: [Select] VarChar Username Var CharPassWord int Active Ted TedsPW 1 something like the above(assuming it formatted correctly. In my php script I will want to input a variable for Username to check for: inputUN in this example would be "Ted". $UserNameToCheck = $_GET['inputUN']; Then I want to check for that UserName in the database, if it exists, I want pull the value for the "Active" field for just that UserName and echo it. Thanks for any help. When there is a duplicate entry in my database, I would like it to go to the another page that indicates the error, rather than the "Error: Duplicate entry 'username' for key 1". It happens if someone is going to join and there is a duplicate entry. I would rather it show one of my customized php pages rather than a black page stating the error. I've tried to catch the entry with some php code but it bypasses it and continues with the duplicate error. I would appreciate any direction with this. Thanks! Hello everybody,
I am new to php, I have a question for you guys.
why I've got an empty page.
<?php Hello,
I've tried to get a dynamic table from an external page, and searching for entries in it, so i used a dynamic XLS file using php excel reader. I only exported the file, but i couldn't search for data.
Can i get some help please ?
I am using php to upload a file to my server, and at the same time inserting the files name and url into my mysql database.
$sql = "UPDATE uploads SET name = '$name', url='$target_path'"; $statement = $dbh->prepare($sql); $statement->execute();This is working, however, when I upload a new file, rather than making a new entry in my database, it just overwrites the first one. I'm quite new at mysql so was wondering how I would make it add new entrys instead of overwriting the current one? Man, I'm having a rough week with questions--if you're following at home. Basically matching a Coach's first and last name to another table, which if matched will yield information about that coach's team. Code: [Select] // or get user by username $current_user = wp_get_current_user(); $current_first = $current_user->user_firstname; $current_last = $current_user->user_lastname; $current_id = $current_user->ID; echo '<div class="contact_form">'; echo $current_first . ' ' . $current_last .' :: '; $query = "SELECT * FROM schools WHERE coachFirst='".$current_first."' AND coachLast='".$current_last."'"; $result = mysql_query ($query); if(!$result) { echo 'There is not a match for your name.'; } else { while($school= mysql_fetch_array($result)) { echo $school['school'] . ' ' . $school['id']; include(ABSPATH ."wp-content/plugins/my-team/form.php"); } echo '</div>'; echo '<div class="roster">'; include(ABSPATH ."wp-content/plugins/my-team/roster.php"); echo '</div>'; } What I am looking for is that if any field in a database is empty, the form comes back and puts in the word "empty" into the web page, but not the database. I got this right now, it shows the first part fine, but the second part it doesn't show the "Empty" comment... I don't understand why... as far as I can tell the code is fine... Code: [Select] <?php //Nonconformity, Disposition, Comments and Comments & Additional Details echo '<div id="box3">'; if (!empty($row['Nonconformity']) || !empty($row['Disposition']) || !empty($row['Comments']) || !empty($row['CommentsAdditional_Details'])) { echo '<div id="non"><span class="b">Nonconformity: </span><br />' . $row['Nonconformity'] . '</div>'; echo '<div id="dis"><span class="b">Disposition: </span><br />' . $row['Disposition'] . '</div>'; echo '<div id="comm"><span class="b">Comments: </span><br />' . $row['Comments'] . '</div>'; echo '<div id="comma"><span class="b">Comments and/or Additional Details: </span><br />' . $row['CommentsAdditional_Details'] . '</div>';} else if (empty($row['Nonconformity']) || empty($row['Disposition']) || empty($row['Comments']) || empty($row['CommentsAdditional_Details'])) { echo '<div id="non"><span class="b">Nonconformity: </span><br />Empty</div>'; echo '<div id="dis"><span class="b">Disposition: <br /></span>Empty</div>'; echo '<div id="comm"><span class="b">Comments: <br /></span>Empty</div>'; echo '<div id="comma"><span class="b">Comments and/or Additional Details: </span><br />Empty</div>';} echo '</div>'; ?> I have a div that displays the contents of a mysql table. When the users adds to the table/presses a button I want it to fade out, reload, and fade back in with the new content there. The current PHP code is in its own div called 'stream'... <script> function buttonFunction() { v=$("#txtstatus"); $.post('../action/poststatus.php',{status:v.val()},function(d){ $('div#stream').fadeOut('slow'); $('div#stream').load; $('div#stream').fadeIn('slow'); }); } </script>This fades out and back in but with nothing new loaded. Please help. Thanks, Hi is there any way we can prevent suppose <textarea></textarea> when page reload it refresh and set default text i wanted to know is there any way to prevent certain things not to get refreshed is there any method in php which prevent to reload this ! <?php echo "<textarea > Enter your favorite quote!</textarea> \n" ; Code: [Select] if (isset($_GET['edit']) && $_GET['edit'] == 'textupdate'){ } <a href= \"{$_SERVER['PHP_SELF']}?page=1&edit=textupdate \" >Click</a>?> |