PHP - Turn Off Form After Set Number Of Submissions
How do you turn off a php form after a set number of submissions? My form is not hooked up to a mysql database. Theoretically I think I would need to set something up that increments a number with each successful form submission. Then when the form hits a certain limit number like 300 it shuts off or hides the div that contains the form. Has anyone done something like this before? Any help or even just pointing me in the right direction is greately appreciated!
Similar TutorialsI have multiple PHP forms set up. Most of them have few fields that if not filled up the form will not be submitted. And one question that if you answer wrong you will not get through either. With this I have eliminated most "hgdgfgdhsj" style forms submissions by spam bots. But every now and then I get ghost or empty form submission. In database I get records (only one at a time) that are fully blank (every now and then). This confuses me. How and why does it happen, and mainly how do I prevent it? Thanks Hi, How would I do this, I'm trying to create a function to turn the octal (not sure whats its called exactly) input into its numberic representation, like so: <?php function octal_to_number($input) { //do something... return $number; } //would turn 0x17c into 380... echo octal_to_number('0x17c'); ?> Lets say a website is dedicated to two different people (Bob and Richard). The site has a contact page in which people can email the two people. Is it possible to create a form in which someone can enter a message but there are two submission options. So in this example there are two images. One reads "Send Email to Bob" and the other reads "Send Email to Richard". Is it possible to do this or to have two submission methods from one form? Is it possible to submit two upload input types on a form. Ex. I'm using a basic form input file upload, and would like to use a php_self to upload since its just one small file. But I also need a second set of files up to 10 files to be upload via a flash upload script. how can i set the form action to process itself (the php coding up top) then process the upload.php file? would if work if i just stuck and execute for the upload.php at the bottom of the php coding for the first upload process? The user uploads a csv file then is required to upload the supporting files. the csv gets inserted to the db and all the files to the temp folder. the upload.php script processes each file separately so sticking the upload process for the csv in the upload.php file would make it import multiple times everytimes till all the supporting files have been uploaded. i'm trying to avoid that. Code: [Select] <?php if(isset($_POST['submit'])) { // check .csv file has been uploaded... and on the server proceed if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], '../temp/files/')) { $filename = file_get_contents($_FILES['uploadedfile']['name']); $handle = fopen("$filename", "r"); while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) { if(file_exists('/temp/files/'. $data[0] .'.docx')) { rename('/temp/files/'. $data[0] .'.docx', '/docx_files/'. $data[0] .'.docx'); $import="INSERT into kmmb_member1(docx_id,no_ahli,no_pin,nama,no_ic_baru,no_ic_lama) values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]')"; mysql_query($import) or die(mysql_error()); } } fclose($handle); print "Import done"; } else { echo "There was an error uploading the *.csv file, please try again!"; } } else { ?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title></title> <script type="text/javascript"> var swfu; SWFUpload.onload = function () { var settings = { flash_url : "swf_up/swfupload/swfupload.swf", flash9_url : "swf_up/swfupload/swfupload_fp9.swf", upload_url: "swf_up/upload.php", post_params: { "PHPSESSID" : "NONE", }, file_size_limit : "100 MB", file_types : "*.wav", file_types_description : "Wave Files", file_upload_limit : 100, file_queue_limit : 0, custom_settings : { progressTarget : "fsUploadProgress", cancelButtonId : "btnCancel" }, }; swfu = new SWFUpload(settings); } </script> </head> <body> <div id="content"> <h2>Upload</h2> <form id="form1" action="index.php" method="post" enctype="multipart/form-data"> <div id="divSWFUploadUI" style="margin-top: 20px;"> <span>Select .csv file: <input name='uploadedfile' type='file' /><br /> </span> <div class="fieldset flash" id="fsUploadProgress"> <span class="legend">Upload Queue</span> </div> <p id="divStatus">0 Files Uploaded</p> <p> <span id="spanButtonPlaceholder"></span> <input id="btnCancel" type="button" value="Cancel All Uploads" disabled="disabled" style="margin-left: 2px; height: 22px; font-size: 8pt;" /> <br /> </p> </div> </form> </div> </body> </html> <?php } ?> I need to display a number(the number is retrieved from the db) in the form input field such that only the last 4 digits is visbile, the remaining can be masked as * or X or whatever is applicable. I know the last 4 can be obtained as follows: Code: [Select] $number=substr($number,-4,4); But when i hit the submit button the form validates the input field and checks if the number is a valid number of a specific format. Therefore when I click on the submit button then I should still be able to unmask the masked numbers or do something similar that would help me validate the whole number. Code: [Select] <input type="text" name="no" value="<?php if(!empty($number)){ echo $number;} ?>"> I'm getting the dreaded " Invalid parameter number: number of bound variables does not match number of tokens" error and I've looked at this for days. Here is what my table looks like:
| id | int(4) | NO | PRI | NULL | auto_increment | | user_id | int(4) | NO | | NULL | | | recipient | varchar(30) | NO | | NULL | | | subject | varchar(25) | YES | | NULL | | | cc_email | varchar(30) | YES | | NULL | | | reply | varchar(20) | YES | | NULL | | | location | varchar(50) | YES | | NULL | | | stationery | varchar(40) | YES | | NULL | | | ink_color | varchar(12) | YES | | NULL | | | fontchosen | varchar(30) | YES | | NULL | | | message | varchar(500) | NO | | NULL | | | attachment | varchar(40) | YES | | NULL | | | messageDate | datetime | YES | | NULL |Here are my params: $params = array( ':user_id' => $userid, ':recipient' => $this->message_vars['recipient'], ':subject' => $this->message_vars['subject'], ':cc_email' => $this->message_vars['cc_email'], ':reply' => $this->message_vars['reply'], ':location' => $this->message_vars['location'], ':stationery' => $this->message_vars['stationery'], ':ink_color' => $this->message_vars['ink_color'], ':fontchosen' => $this->message_vars['fontchosen'], ':message' => $messageInput, ':attachment' => $this->message_vars['attachment'], ':messageDate' => $date );Here is my sql: $sql = "INSERT INTO messages (user_id,recipient, subject, cc_email, reply, location,stationery, ink_color, fontchosen, message,attachment) VALUES( $userid, :recipient, :subject, :cc_email, :reply, :location, :stationery, :ink_color, :fontchosen, $messageInput, :attachment, $date);"; And lastly, here is how I am calling it: $dbh = parent::$dbh; $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); if (empty($dbh)) return false; $stmt = $dbh->prepare($sql); $stmt->execute($params) or die(print_r($stmt->errorInfo(), true)); if (!$stmt) { print_r($dbh->errorInfo()); }I know my userid is valid and and the date is set above (I've echo'd these out to make sure). Since the id is auto_increment, I do not put that in my sql (though I've tried that too), nor in my params (tried that too). What am I missing? I feel certain it is something small, but I have spent days checking commas, semi-colons and spelling. Can anyone see what I'm doing wrong? Assume this project is to create an online lottery system. Is there a way to limit the user entering the numbers after a certain time? E.g. The Draw will be at 9.00PM 05 November 2010 - Submitting the numbers will expire after 8.00PM 05 November 2010. (so any user tries to submit numbers after 8.00PM 05 Nov 2010 will not be entered in to the MySQL db). Any help is highly appreciated. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=354321.0 Hello, Basically, I'm using srand to generate a number, and if the user gets a specific number, they can win by entering their details into the form. However, I want to block other numbers except from (in this example) 300000. I'm using: <form method="POST" id="form1" name="form1" action="send.php"> Email:<input type="text" id="name" name="email"><br /> <input type="hidden" value="<?php echo $b ?>" name="name" id="name" /> <input type="hidden" value="<? echo $random_number ?>" name="code" id="code" /> <br /><input type="submit" name="submit" value="Submit my code"> </form> With: <?php session_start(); if($_SERVER['REQUEST_METHOD'] === 'POST'){ if(isset($_POST["code"]) && $_SESSION["code"] == $_POST["code"]) { $blacklisted = Array("300000", "##", "##", "##", "##", "##"); $code = $_POST['code']; if( !in_array( strtolower($code), $blacklisted ) ) { $emailblock = '<div id="captchatext">Sorry, that number was not 300000.</div>'; } else { require('send.php'); } }} ?> However, any number entered seems to require send.php. Many thanks Hi, Newbie! I need to generate a unique number and put it in a field called "intInstD" value ="123456" to send to Paypoint to initiate an order. They insist each order from my website has a unique number. Can anyone help with a bit of code that does this please? Much appreciated zzdave Please help me. I'm fairly new to php and have been looking for answers on Goog for about two weeks or so with not an answer. This is my first post on a forum of any type. I have a form on a php page that when submitted sends a value to a confirm php page Code: [Select] <form action='buyconfirmorder.php' method='post'> Purchase: <input type='text' name='ask_shares'><br /><br /> You Will Pay:  <input type='text' name='ask'><br /><br /> <input type='hidden' name='postcardname' value='$postcardname'> <input type='submit' name='submit' value='Order'> </form> I need to take the users input from the form and subtract each row from a mysql DB one at a time until the users input is down to a remainder and then I need the remainder (I'll be working with the remainder as well). Code: [Select] $query = mysql_query(" SELECT * FROM ask, search WHERE search.id = ask.card_search_id AND search.card_name = '$postcardname' ORDER BY ask_price ASC"); The array will be numbers only. So an example would be: User input from the form is 100.00 Code: [Select] while($rows = mysql_fetch_array($query)) { $ask_price = $rows['ask_price']; } Let's say the array is 50.50, 40.50, 35.00 I need some code to do: 100.00 - 50.50 = 49.50 49.50 - 40.50 = 9.00 9.00 - 35.00 = <0 does not do anything so remainder = 9.00 would it be something like Code: [Select] $new_ask_shares = $_POST['ask_shares']; //some sort of a loop or array or combo of both ($new_ask_shares - $ask_price); the numbers are just an example as the actual numbers will be different each time I query my DB. Thanks in advance Hello,
I have problem durring binding update query. I can't find what is causing problem.
public function Update(Entry $e) { try { $query = "update entry set string = $e->string,delimiter=$e->delimiter where entryid= $e->id"; $stmt = $this->db->mysqli->prepare($query); $stmt->bind_param('ssi',$e->string,$e->delimiter,$e->id); $stmt->close(); } catch(Exception $ex) { print 'Error: ' .$ex->getMessage(); } }When I run function update I'm getting next error:Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement Can you help me to solve this problem ? Edited by danchi, 17 October 2014 - 10:25 AM. Hi. I have made profile pages available for users.. How do I turn off <?php ?> for those pages? I would like javascript enabled however. All suggestions are welcome!! Thanks How to turn off notices in PHP 5.3. Is it possible to turn it off in php.ini? Hello All, I'm trying to put a lot of what I do into function calls now to make my code a bit tidier and consise. Take this simple if statement: if ($_GET['thedate'] =='') { $var = date('l, jS F, Y',time()); } else { $var = date('l, jS F, Y', strtotime($_GET['thedate'])); } How could I put this into a function and in some kind of switch statement? Thanks i have apache 2.2 and php 5.0 installed on my pc, i have a html page and i need to turn it into php and also i need to include a header and a footer, i tryed doing it but the webpage won't display, what am i doing wrong? here is my page which i tryed turning into php <!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" xml:lang="en" lang="en"> <!--index.html is basically an introductory page to this website, this page introduce us to this website. This page tell us, this page is called index.html because that's the name of the first page on any website, this page tell us wat type of website this is, name of this website, name of the person(in this case that's me) who made it, a light description of what type of contents we will find inside this website etc. This page tell us the name of this lab assignment which is " --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>INTN2201 - Lab 1</title><!--title of this page --> <link href="./css/intn2201.css" rel="stylesheet" type="text/css" /></head> <body> <table border="1" > <tr> <td class="navmenu"><img src="images/my_logo.jpg" alt="My Logo" /></td> <td class="page_header"><h1>INTN 2201: Lab Assignment 1: HTML Pages</h1></td> </tr> <tr> <td valign="top"> <a href="index.html" >MY HOME PAGE</a> <br /> <a href="lab1.html" >LAB 1:HTML Intro</a> <br /> <a href="lab2.html" >LAB 2:HTML Tables</a> <br /> <a href="lab3.html" >LAB 3:CSS Styles</a> </td> <td class="main_body"><h2> Purpose of this website</h2> <p class="p1"> This website was created for first lab assignment of <a href="http://opentech.durhamcollege.ca/~pufferd/intn2201">INTN2201</a>, <a href="http://opentech.durhamcollege.ca/~pufferd/intn2201">INTN2201</a> is the course code for "INTERNET DEVELOPMENT I" course, at <a href="http://www.durhamcollege.ca">Durham College</a> every first year student<br/> of Computer System Technology program(3 years) have to take this course, main purpose of this site is to get a first feel for creating a basic html website<br/> but also to get a feel of how to use it in website creation, during the creation of this page i get to know programs like notepad++,<br/> WINSCP, learned how to login to course webserver(opentech.durhamcollege.ca), another purpose for this site is to test webpage creator's( in this case that's me)<br/> knowledle about HTML tags, XHTML, W3C validator, HTML stands for Hyper Text,it is not a programming language it is a Markup Language,<br/> I(creater of this website) wanted to learn about differen't html tags and one of the best ways to learn about html tags is to try create<br/> a html webpage. </p> <hr/> <h2>ol { margin-left : 200px; } </h2> <p class="p2"> in this style tag i used Margine properties to define a list in lab2.html, bottom of the page u will see lists, so margine basically sets all the margin properties in one declaration.</p> <hr/> <a href="http://www.durhamcollege.ca/"> <img width="300" src="images/durham_college_logo.jpg" alt="My Logo" /></a> <hr/> </td> </tr> <tr> <td class="navmenu" colspan="2" align="right"> ©2011 <p> <a href="http://validator.w3.org/check?uri=referer"> <img style="width:88px; height:31px; position:fixed; bottom: 81px; left:50px;" src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" /> </a> </p> <p> <a href="http://jigsaw.w3.org/css-validator/check/referer"> <img style="width:88px; height:31px; position:fixed; bottom: 45px; left:50px; " src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" /> </a> </p></td> </tr> </table> </body> </html> how do i turn this into php page and what goes in the header and footer? I've tried to find an answer in the forum and although there have been posts similar I am unable to covert the answer to fit what I've got (mostly because I know very very little about php - sorry). What I need is one of the results to be added to the end of a url in order to create a link. Basically I have a storefront (www.storefront.com/) and the result NAME can be added onto the end of our url to create a link to the product page. (www.storefront.com/NAME) Code: [Select] <?php $dbhost = ""; $dbuser = ""; $dbpass = ""; $dbname = ""; //Connect to MySQL Server mysql_connect($dbhost, $dbuser, $dbpass); //Select Database mysql_select_db($dbname) or die(mysql_error()); // Retrieve data from Query String $price = $_GET['price']; $taxable = $_GET['taxable']; $weight = $_GET['weight']; // Escape User Input to help prevent SQL Injection $age = mysql_real_escape_string($price); $sex = mysql_real_escape_string($taxable); $wpm = mysql_real_escape_string($weight); //build query $query = "SELECT * FROM Products WHERE taxable = '$taxable'"; if(is_numeric($price)) $query .= " AND price <= $price"; if(is_numeric($weight)) $query .= " AND weight <= $weight"; //Execute query $qry_result = mysql_query($query) or die(mysql_error()); //Build Result String $display_string = "<table>"; $display_string .= "<tr>"; $display_string .= "<th>Name</th>"; $display_string .= "<th>Price</th>"; $display_string .= "<th>Taxable</th>"; $display_string .= "<th>Weight</th>"; $display_string .= "</tr>"; // Insert a new row in the table for each person returned while($row = mysql_fetch_array($qry_result)){ $display_string .= "<tr>"; $display_string .= "<td>'<a href="www.storefront.com/">' . $row[name] . ' </a>'/td>"; $display_string .= "<td>$row[price]</td>"; $display_string .= "<td>$row[taxable]</td>"; $display_string .= "<td>$row[weight]</td>"; $display_string .= "</tr>"; } echo "Query: " . $query . "<br />"; $display_string .= "</table>"; echo $display_string; ?> I know the way it is setup in the code is wrong. Can anyone help me out? Would really appreciate it. Thanks - and again, sorry for my lack of php knowledge. How do I turn a checkbox on or off programatically? My form has several checkboxes that are grouped together and I want them to be turned on initially when the user first sees the form.I can do that very easily by just including "checked" in the HTML for the checkbox. But if the user turns off the checkbox before he presses Submit, I want to make sure I show the ones that are off as off when I redisplay the form as a result of errors in other fields, like textareas. How do I turn the checkbox off or on within my PHP code? Edited June 9, 2019 by HenryCanHi. I have a problem with output buffering. I'm using wamp. I've tried setting the php.ini file to output_buffering = 0 and off I've tried using flush() and ob_flush(), separetly and together. I've tried turning on implicit_flush. Nothing works. Any ideas? I'm using the flowing code to test right now: Code: [Select] echo 'starting...<br/>'; for($i = 0; $i < 5; $i++) { print "$i<br/>"; flush(); sleep(2); } print 'DONE!<br/>'; I've tried to use this http://www.bambalam.se/bamcompile/ .. but I cant get curl to work using the option to set the extension.. I need it to be able to sign into myspace or facebook with curl when it is in an exe.. everything else works fine with bambalam, everything but curl and connecting to an mysql db, I dont need to have mysql support, only curl.. what would be the easiest way to make this happen? btw the exe should just open a CLI and run the script, thanks |