PHP - 2 Submit Buttons In The Form Of An Image.
One submit button goes to my own login system.. the other goes to a billing system.
I am having problems getting it to work probably because there are alot of if and else if statements. Or maybe I am just missing something. The problem is the line with blesta.. I take that if isset out and just start with if permission =1 then all is great but I need both of them to operate .. with one being sent to one place and the other to another one. the login file and my form has both input types ready to go within it.. I can declare the values I just need to know what I am doing wrong in the if statement. Code: [Select] <input type="image" name="blesta" id="BtnSubmit" src="images/cart.jpg" width="25" height="20" submit="Blesta"></td> <td><input name="login" type="image" class="vote" src="images/index19.jpg" submit="login"></td> Code: [Select] <? session_start(); $username = $_SESSION["username"]; ?> <html><body> <title>Login</title> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td class="poptop" height="10"><img src="password/images/spacer.gif" width="3" height="3"><img src="logo.png" border="0"></td> </tr> <tr> <td class="hrz_line"><img src="password/images/spacer.gif" width="1" height="1"></td> </tr> <tr> <td style="background: #ffffff; padding: 5px" valign="middle"><h1 style="margin-top: 0; margin-bottom: 0">Welcome<br><br> Newest User: <font style="FONT-FAMILY: Verdana; FONT- SIZE: 7pt"><?php $connect = mysql_connect("localhost", "username", "pw") or die("Could not connect to database: " . mysql_error()); mysql_select_db("db", $connect) or die("Could not select database"); $query = "SELECT * FROM users ORDER BY created DESC LIMIT 1"; $result = mysql_query($query, $connect) or die ("QUERY FAILED: " . mysql_error()); $row = mysql_fetch_array($result,MYSQL_ASSOC);?> <?echo $row[username]; ?></td></h1></font> </tr> <tr> <td class="hrz_line"><img src="password/images/spacer.gif" width="1" height="1"></td> </tr> <tr> <td valign="top" style="padding: 1em" class="maincontent" height="90"> <META HTTP-EQUIV="expires" CONTENT="0"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <link rel="stylesheet" type="text/css" href="style.css"> <?php $connect = mysql_connect("localhost", "user", "pw") or die("Could not connect to database: " . mysql_error()); mysql_select_db("db", $connect) or die("Could not select database"); $login = $_POST["username"]; $password = $_POST["password"]; $field = ""; if (isset($_POST["username"]) and isset($_POST ["password"])) { if (is_numeric('$login')) { $field = "user_id"; } else { $field = "username"; } $query = sprintf ("SELECT * FROM users WHERE $field='$login' AND password='".md5 ($password)."'", mysql_real_escape_string($login), mysql_real_escape_string($password)); $result = mysql_query($query, $connect) or die ("QUERY FAILED: " . mysql_error()); if (mysql_num_rows($result) == 0) { if(session_is_registered("LoginFailed")) { if($_SESSION['LoginFailed'] > 3) { $user_query = mysql_query("SELECT * FROM users WHERE username = '$login'") or die("QUERY FAILED: " . mysql_error()); $user = mysql_query($user_query); $hostname = gethostbyaddr($_SERVER ['REMOTE_ADDR']); $password_cypt = md5($password); $date = date("YmdHis"); $IP = getenv("REMOTE_ADDR"); $browser = getenv("HTTP_USER_AGENT"); $handle = fopen("ban.txt", "a+"); //echo "sql: ".$query.""; //echo "Login Failed!"; $access_query = "INSERT INTO hacklog (date, username, hostname, ip_address, browser, refer, password) values ('$date', '$login', '$hostname', '$IP', '$browser', '$refer', '$password')" or die("QUERY FAILED: " . mysql_error()); $access = mysql_query($access_query) or die ("QUERY FAILED: " . mysql_error()); $browser = getenv("HTTP_USER_AGENT"); $hostname = gethostbyaddr($_SERVER ['REMOTE_ADDR']); $date = date("YmdHis"); $rest = substr(getenv('SCRIPT_NAME'), 1, -4); mail("email", "Hack Attack Alert", "Someone Is Attempting To Enter V.I.P\nThe username is: $login\nPassword is: $password\nIP is: $visitorip\nHostname is: $hostname\nBrowser Used is: $browser\nDate: $date\nFile: $rest", "From: email\n"); $browser = getenv("HTTP_USER_AGENT"); $date = date("YmdHis"); $hostname = gethostbyaddr($_SERVER ['REMOTE_ADDR']); $IP = getenv("REMOTE_ADDR"); $handle = fopen("ban.txt", "a+"); $date = date("m-d-Y H:i:s"); $somecontent = $IP.", ".$date. ", ".$browser.", ".$hostname.""; fwrite($handle, $somecontent . " "); fclose($handle); echo "$IP Is Now Banned. Follow Instructions On Next Screen."; print "<META HTTP-EQUIV=\"Refresh\" target= \"info\" Content=\"1; URL=ban.php\">"; exit(); } else { $_SESSION['LoginFailed'] = $_SESSION ['LoginFailed'] + 1; print "<p><strong>Now " . $_SESSION ['LoginFailed'] . " out of 4 Attempts Used</strong></p>\n"; print "<META HTTP-EQUIV=\"Refresh\" Content=\"1; URL=error.php?msg=pass\">"; exit(); } } else { $_SESSION['LoginFailed'] = 1; print "<p><strong>You have used " . $_SESSION ['LoginFailed'] . " out of 4 trys</strong></p> \n"; print "<META HTTP-EQUIV=\"Refresh\" Content=\"1; URL=error.php?msg=pass\">"; exit(); } print "<META HTTP-EQUIV=\"Refresh\" Content=\"1; URL=error.php?msg=pass\">"; exit(); } else { $date = date("YmdHis"); $session = md5($date); $password_cypt = md5($password); $row = mysql_fetch_array($result,MYSQL_ASSOC); $hostname = gethostbyaddr($_SERVER ['REMOTE_ADDR']); $IP = getenv("REMOTE_ADDR"); $browser = getenv("HTTP_USER_AGENT"); $_SESSION["logged"] = "1"; $_SESSION["id"] = $row["user_id"]; $_SESSION["username"] = $row["username"]; $_SESSION["firstname"] = $row["firstname"]; $_SESSION["lastname"] = $row["lastname"]; $_SESSION["email"] = $row["email"]; $_SESSION["created"] = $row["created"]; $_SESSION["last_access"] = $row["last_access"]; $_SESSION["pw"] = $row["pw"]; $_SESSION["permission"] = $row["permission"]; $_SESSION["count"] = $row["count"]; $_SESSION["photo"] = $row["photo"]; $_SESSION["session_id"] = $row["session_id"]; //echo "sql: ".$query."<br>"; //echo "Login success: username: ".$_SESSION ["username"]; //Find Last Access $dd = substr($_SESSION[last_access],6,2); $mm = substr($_SESSION[last_access],4,2); $yyy = substr($_SESSION[last_access],0,4); $HH = substr($_SESSION[last_access],8,2); $MM = substr($_SESSION[last_access],10,2); $SS = substr($_SESSION[last_access],12,2); $access2 = "$mm-$dd-$yyy $HH:$MM:$SS"; $username = $_SESSION["username"]; $access = "$access2"; $login_message = "<p><br> Login Successful.<br><br> [$username] , Last Visited MalenTek On: [$access]<br>Loading Please Wait..<img src=password/images/ajax-loader.gif border=0></p>\n"; if (isset($_POST['blesta']) { print "You are being redirected to your Billing Account"; print "<META HTTP-EQUIV=\"Refresh\" Content= \"10; URL=/cart/u-main.php">"; } else if ($_SESSION[permission] == "1") { $connect = mysql_connect("localhost", "user", "pw") or die("Could not connect to database: " . mysql_error()); mysql_select_db("db", $connect) or die("Could not select database"); mysql_query("UPDATE users SET last_access = $date WHERE username = '$username'")or die("QUERY FAILED: " . mysql_error()); include ("file.php"); print "$login_message"; print "<META HTTP-EQUIV=\"Refresh\" Content=\"10; URL=password/admin.php\">"; } else if ($_SESSION[permission] == "0") { $connect = mysql_connect("localhost", "user", "pw") or die("Could not connect to database: " . mysql_error()); mysql_select_db("db", $connect) or die("Could not select database"); mysql_query("UPDATE users SET last_access = $date WHERE username = '$username'")or die("QUERY FAILED: " . mysql_error()); include ("file.php"); print "$login_message"; print "<META HTTP-EQUIV=\"Refresh\" Content=\"10; URL=members.php/">"; } else if ($_SESSION[permission] == "2") { mysql_query("UPDATE users SET last_access = $date WHERE username = '$username'")or die("QUERY FAILED: " . mysql_error()); include ("ban.php"); print "$login_message"; print "<META HTTP-EQUIV=\"Refresh\" Content=\"10; URL=index.php\">"; } //} } } ?> </td> </tr> <tr> <td class="hrz_line"><img src="images/spacer.gif" width="1" height="1"></td> </tr> <tr> <td height="20" class="popbot"><a href="mailto:email Errors">Report Errors</a></td> </tr> </table> </body> </html> Similar TutorialsSo I have created an online test . I have the results from the form submitted to my email. It is working great but the only problem is that when a question is left unanswered, the radio button doesn't have a result. What i want it to do is when a question is left unanswered, the email should look like this (Question) 1_01: True 1_02: Unanswered 1_03: False 1_04: Unanswered 1_05: True Right now it looks like this: (Question) 1_01: True 1_03: False 1_05: True I can't make the radio button required because it is a timed test where you have to work fast, so unanswered questions are going to happen. How do I make it so that unanswered radio buttons submit the value "unanswered" in the E-mail? How do i display the image uploaded after the form has been submitted? After the form is submitted it will be a preview page, so i'm not storing the image type BLOB in MySQL yet. How do i display $_FILES['image']? Code: [Select] <?php if(isset($_POST['submit'])) { //preview page $info = getimagesize($_FILES['image']['tmp_name']); $imagetype = $info['mime']; $tmpname = $_FILES['image']['tmp_name']; $fp = fopen($tmpname,'r'); $data = fread($fp,filesize($tmpname)); $data = addslashes($data); fclose($fp); } else { ?> <form enctype="multipart/form-data" action="http://www.example.com/submit" method="POST"> <input type="file" name="image" value="" size="50" /> <input type="submit" name="submit" value="submit" /> </form> <?php } ?> Hi, I am new to php and I desperately need help inserting an image into my php submit form. The form works perfectly but I have no idea how to get an image to be shown when the recipeint fo the email receive it (would love to have my company logo at the top of the mail just after $message.. Below is my code : .... // Create Mail Message and Send Mail $to = 'x@domain.coma'; $subject = "Website Enquiry Received from www.domain.com"; $message = "The following message has been sent from the website." . "\n" . "\n" . "Date Sent: " . date("j F Y") . "\n" . "Date Sent: " . date("g:i a") . "\n" . "\n" . "From: $contactName $contactSurname" . "\n" . "\n" . "Their Contact & Personal Details" . "\n" . "=====================" . "\n" . "\n" . "Marital Status: $contactStatus" . "\n" . "Email: $contactEmail" . "\n" . "Cellphone Number: $contactNumber" . "\n" . "Address 1: $contactAddress1" . "\n" . "Address 2: $contactAddress2" . "\n" . "Suburb: $contactSuburb" . "\n" . "Postal Code: $contactPostalcode" . "\n" . "\n" . "\n" . $headers = "From: $contactName $contactSurname <$contactEmail>" . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); mail($contactEmail, 'Confirmation of email: "' . $subject . '"', $message, $headers); // Thank You Message header('Refresh: 0; url=/quote_confirm.htm'); } } ?> I was wondering if you can have a form that has different actions depending on what submit button is pressed. I have two button and with one I was to use <form action="<?php echo ( $_SERVER['PHP_SELF'] ); ?>" method="post"> and with the other I want to use <form action="preview.php" method="post"> I was to do this because I want to user to be able to preview their content before submitting. I want the preview page to use the post variables as the value of the input fields so the user doesn't have to input their data again. However because the form doesn't redirect the user to the preview page I have to save all the post variables as session variables. I can't figure out why my $_POST['join'] isn't working. Does my form need to be inside my foreach? Code: [Select] <?php if(is_admin($user_info['uid'], $info['companyid']) === false) { if (isset($_POST['join'])) { echo "works"; die(); } $companies = fetch_company_by_name($info['cname']); ?> <table class="feed pts pbl"> <?php foreach ($companies as $company) { ?> <tr class="mbm"> <td> <form method="post" id="ccreateform" class="man"> <input type="submit" name="join[<?php echo $company['companyid']; ?>]" value="Join" /> </form> </td> </tr> <?php } ?> </table> <?php } ?> I'm new to PHP and attempting to set up my first interactive site that is a basic survey for little kids to take. There's a picture shown to them and two submit buttons below the pic, one reads YES and the other NO to register whether they've participated in the activity before or not. Since the only thing that changes on the page after the selection is made is the photo for the next question/activity, I'd like to be able to use the two buttons to both send their choice to a database (Yes=1 and No=2) and also increment a counter so I can update the picture on the page as they progress through the survey. All the information I've searched/read so far on submit buttons and multiple page surveys doesn't use the actual button itself as data but it's used to submit information gathered elsewhere on the page to another php page for processing via the Action attribute, so I'm wondering if what I want can be done. I'm leaving the Action attribute blank for each button as I want to stay on the same page and attempting to use an incremental counter to update the picture on the page in order to "step" through the survey each time one of the two buttons is clicked, but not having any luck and would appreciate suggestions or points in the right direction on the best way to do this. Apologies in advance if this seems like a basic question, and thanks for any suggestions you can offer. 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 I think I understand that there can only be one "submit" button on a page.
I want buttons for separate forms to not trigger the empty errors on the other forms...
How do you accomplish specific button actions?
I think I've tried it with javascript but you can do it with PHP right?
Thanks for any help.
Hi. Pretty straight forward I guess but as the name suggests am a newbie. I have a form that requires the user to enter certain parameters. If the values are blank it submits to itself and loads the error messages. What I want to do is create PHP code that submits the form to a different url. What I thought was create two forms (the second with hidden fields replicating the first form), each form having a different url in the action"" code. What I cant work out is the PHP IF ELSE code to submit form 2 if Form1 is is validated correctly. This is the PHP code relevant to the form validation. Help? <?php //If form was submitted if ($_POST['submitted']==1) { $errormsg = ""; //Initialize errors if ($_POST[width]){ $title = $_POST[width]; //If title was entered } else{ $errormsg = "Please enter width"; } if ($_POST[drop]){ $textentry = $_POST[drop]; //If comment was entered } else{ if ($errormsg){ //If there is already an error, add next error $errormsg = $errormsg . " & content"; }else{ $errormsg = "Please enter drop"; } } } if ($errormsg){ //If any errors display them echo "<div class=\"box red\">$errormsg</div>"; } //If all fields present if ($title && $textentry){ //Do something echo 'THIS IS WHERE I WANT THE CODE TO SUBMIT FORM 2 or SUBMIT FORM 1 TO A DIFFERENT URL'; } ?> Hello, first time poster.. I've looked the web over for a long time and can't figure this one out. - Below is basic code that successfully checks MySQL for a match and displays result. I was debugging and forced the "height" and "width" to be 24 and 36 to make sure that wasn't the problem. That's good.. - I'd like to give the user ability to select width and height from a form.. and have it do an onchange this.form.submit so the form can be changing as fields are altered (thus the onchange interaction) - In a normal coding environment I've done this numerous times with no "Page cannot be displayed" problems. It would simply change one select-option value at a time til they get down the form and click submit... but in WordPress I'm having trouble making even ONE single onchange work! - I've implemented the plugins they offer which allows you to "copy+paste" your php code directly into their wysiwyg editor. That works with basic tests like my first bullet point above. - I've copied and pasted the wordpress url (including the little ?page_id=123) into the form "action" url... that didn't work... tried forcing it into an <option value=""> tag.. didn't work. I'm just not sure. I've obviously put xx's in place of private info.. Why does this form give me Page Cannot Be Displayed in WordPress every time? It won't do anything no matter how simple.. using onchange.. Code.. $con = mysql_connect("xxxx.xxxxxxx.com","xxxxxx","xxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxxxxx", $con); $myprodwidth=24; $myprodheight=36; $result = mysql_query("SELECT * FROM product_sizes WHERE prodwidth='$myprodwidth' and prodheight='$myprodheight'"); while($row = mysql_fetch_array($result)) { echo $row['prodprice']; } mysql_close($con); <form method="post" action=""> <select name="myheight" onchange="this.form.submit();"> <option selected="selected" value="">select height</option> <option value="xxxxxxxxx.com/wordpress/?page_id=199&height=36">36</option> <option value="xxxxxxxxx.com/wordpress/?page_id=199&height=36">48</option> </select> Hi all, What I am trying to achieve is, I thought quite simple! Basically, a user signs up and chooses a package, form is submitted, details added to the database, email sent to customer, then I want to direct them to a paypal payment screen, this is where I am having issues! Is their any way in php to submit a form without user interaction? Here is my code for the form process page Code: [Select] <?php include('config.php'); require('scripts/class.phpmailer.php'); $package = $_POST['select1']; $name = $_POST['name']; $email = $_POST['email']; $password = md5($_POST['password']); $domain = $_POST['domain']; $a_username = $_POST['a_username']; $a_password = $_POST['a_password']; $query=mysql_query("INSERT INTO orders (package, name, email, password, domain, a_username, a_password) VALUES ('$package', '$name', '$email', '$password', '$domain', '$a_username', '$a_password')"); if (!$query) { echo "fail<br>"; echo mysql_error(); } else { $id = mysql_insert_id(); $query1=mysql_query("INSERT INTO customers (id, name, email, password) values ('$id', '$name', '$email', '$password')"); if (!$query1) { echo "fail<br>"; echo mysql_error(); } if($package=="Reseller Hosting") { //email stuff here - all works - just cutting it to keep the code short if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } ?> <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <input type="hidden" name="business" value="subscription@jollyhosting.com"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="item_name" value="Jolly Hosting Reseller Packages"> <input type="hidden" name="no_shipping" value="1"> <!--1st month --> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="a3" value="3.00"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="M"> <input type="hidden" name="src" value="1"> <input type="hidden" name="sra" value="1"> </form>'; <?php } //last } //end ?> Hi- the code below lets me upload a CSV file to my database if I have 1 field in my database and 1 column in my CSV. I need to add to my db "player_id" from the CVS file and "event_name" and "event_type" from the form... any ideas??? here's the code: Code: [Select] <?php $hoststring =""; $database = ""; $username = ""; $password = ""; $makeconnection = mysql_pconnect($hoststring, $username, $password); ?> <?php ob_start(); mysql_select_db($database, $makeconnection); $sql_get_players=" SELECT * FROM tabel ORDER BY player_id ASC"; // $get_players = mysql_query($sql_get_players, $makeconnection) or die(mysql_error()); $row_get_players = mysql_fetch_assoc($get_players); // $message = null; $allowed_extensions = array('csv'); $upload_path = '.'; //same directory if (!empty($_FILES['file'])) { if ($_FILES['file']['error'] == 0) { // check extension $file = explode(".", $_FILES['file']['name']); $extension = array_pop($file); if (in_array($extension, $allowed_extensions)) { if (move_uploaded_file($_FILES['file']['tmp_name'], $upload_path.'/'.$_FILES['file']['name'])) { if (($handle = fopen($upload_path.'/'.$_FILES['file']['name'], "r")) !== false) { $keys = array(); $out = array(); $insert = array(); $line = 1; while (($row = fgetcsv($handle, 0, ',', '"')) !== FALSE) { foreach($row as $key => $value) { if ($line === 1) { $keys[$key] = $value; } else { $out[$line][$key] = $value; } } $line++; } fclose($handle); if (!empty($keys) && !empty($out)) { $db = new PDO( 'mysql:host=host;dbname=db', 'user', 'pw'); $db->exec("SET CHARACTER SET utf8"); foreach($out as $key => $value) { $sql = "INSERT INTO `table` (`"; $sql .= implode("`player_id`", $keys); $sql .= "`) VALUES ("; $sql .= implode(", ", array_fill(0, count($keys), "?")); $sql .= ")"; $statement = $db->prepare($sql); $statement->execute($value); } $message = '<span>File has been uploaded successfully</span>'; } } } } else { $message = '<span>Only .csv file format is allowed</span>'; } } else { $message = '<span>There was a problem with your file</span>'; } } ob_flush();?> <!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>CSV File Upload</title> </head> <body> <form class="form" action="" method="post" enctype="multipart/form-data"> <h3>Select Your File</h3> <p><?php echo $message; ?></p> <input type="file" name="file" id="file" size="30" /> <br/> <label>Event Name:</label><input name="event_name" type="text" value="" /> <br/> <label>Event Type:</label><input name="event_type" type="text" value="" /> <br/> <input type="submit" id="btn" class="button" value="Submit" /> </form> <br/> <h3>Results:</h3> <?php do { ?> <p><?php echo $row_get_players['player_id'];?></p> <?php } while ($row_get_players = mysql_fetch_assoc($get_players)); ?> </body> </html> i created 2 buttons and how do i pass value of one i click on so i have yes and no button do i need 2 different forms or 1 with different values? any tip, tutorial or code will help I have the following Form Buttons in my Inbox page... Code: [Select] <input type="submit" name="cmdGo" class="" value="Go"/> <input id="createPM" type="submit" name="createPM" class="" value="Create PM"/> If the I submit the Form, apparently both Buttons get passed over in the $_POST array. The problem is that since you can't click on both Buttons, my code is giving me this error... Quote Notice: Undefined index: createPM The error above refers to this code... if ($_POST['createPM']=="Create PM"){ // Redirect to Send PM page. header("Location: " . BASE_URL . "/account/send_pm.php"); // End script. exit(); } What would be the best way to handle this issue? Thanks, Debbie Hello All,
I'm kinda new to PHP and web development and I seem to have a very wierd problem which is driving me nuts (for the last 2 days)...so I'd appreciate any and all help in getting it resolved.
Okay, so here's the problem:
In the code below, I used to have just the first statement below...which essentially accepted input as a textbox for a text field named qty_pkg (in the underlying MySQL table)...and that used to work just fine.
So then I decided to change the input type for that field to be a radio button, accepting one of two choices i.e. "UoM" or "Qty", and therefore I added the remainder of the code, whilst also commenting/remarking out the first statement.
What happens (when I added the radiobutton-related code) is that control no longer goes into the TRUE portion/logic of the "if ( !empty($_POST))" condition-check, but rather, it seems to go into the "ELSE/FALSE" portion of that conditional check. However, a record does get added to my table, even though I do not have an "INSERT INTO..." clause in the ELSE porition of that check. Also, what gets displayed on screen is as follows:
------------------------------------------------------------------------------------------------------------------------------------
Array()
There's something wrong somewhere!!!
Array()
------------------------------------------------------------------------------------------------------------------------------------
Now, if/when I comment/remark the radiobutton-related code, the "if ( !empty($_POST))" logic seems to work fine and the following is displayed on screen (which is what I expect):
------------------------------------------------------------------------------------------------------------------------------------
Array ( [datepicker] => 10/30/2014 [store_id] => 48 [new_store_name] => [item_id] => 5 [new_item_name] => [pkg_of] => 1 [price] => 1 [flyer_page] => 1 [limited_time_sale] => Array ( [0] => fri [1] => sat ) [nos_to_purchase] => 1 [create-and-add-more] => Create and Add More ) Notice: Undefined index: qty_pkg in /var/www/create.php on line 54 Array ( [0] => Array ( [item_id] => 5 [0] => 5 [item_name] => BD Cheese Strings [1] => BD Cheese Strings [section_id] => 7 [2] => 7 ) ) ------------------------------------------------------------------------------------------------------------------------------------ The other wierd thing is that if/when I now uncomment the first statement (which used to work just fine before) the "if ( !empty($_POST))" logic no longer seems to work the way it used to. Does/can someone see something wrong with my code somewhere? <!-- <?php echo standardInputField('Qty / Pkg', 'qty_pkg', $qty_pkg, $errors); ?> --> <div class="control-group"> <label class="control-label">Priced by:</label> <div class="priced-by-radio-container"> <div class="pb-radiobuttons-container"> <label class="indent-to-the-left"> <input class='priced-by-radiobutton' type='radio' name='qty_pkg' value='UoM' $pb1> <span class='no-highlight'>Unit of Measure</span> </label> <label> <input class='priced-by-radiobutton' type='radio' name='qty_pkg' value='Qty' $pb2> <span class='no-highlight'>Quantity</span> </label> </div> </div> </div> <?php echo standardInputField('UoM Name/Pkg. Of:', 'pkg_of', $pkg_of, $errors); ?> <?php echo standardInputField('Price:', 'price', $price, $errors); ?> <?php echo standardInputField('Flyer Page #:', 'flyer_page', $flyer_page, $errors); ?> print_r($_POST); if ( !empty($_POST)) { // keep track of $_POST(ed) values by storing the entered values to memory variables $store_id = $_POST['store_id']; $item_id = $_POST['item_id']; $qty_pkg = $_POST['qty_pkg']; $pkg_of = $_POST['pkg_of']; ... ... $sql = "INSERT INTO shoplist (store_id,item_id,qty_pkg,pkg_of,price,flyer_page,limited_time_sale,flyer_date_start,nos_to_purchase,section_id,shopper1_buy_flag,shopper2_buy_flag,purchased_flag,purchase_later_flag,no_flag_set) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; $q = $pdo->prepare($sql); $q->execute(array($store_id,$item_id,$qty_pkg,$pkg_of,$price,$flyer_page,$limited_time_sale,$flyerDateStart,$nos_to_purchase,$section_id,$initialize_flag_N,$initialize_flag_N,$initialize_flag_N,$initialize_flag_N,$initialize_flag_Y)); } else { echo "<br />There's something wrong somewhere!!!<br />"; print_r ($_POST); $qty_pkg = ''; $pkg_of = '';;Thanks. Can anybody see as to why, if any, this form takes forever to execute? Code: [Select] <?php if(isset($_POST['submitted'])){ $z = $_POST['zipcode']; $r = $_POST['radius']; $sql = mysql_query("SELECT DISTINCT m.LocAddZip, m.MktName,m.LocAddSt,m.LocAddCity,m.LocAddState,m.x1,m.y1,z1.lat,z2.long FROM mrk m, zip z1, zip z2 WHERE m.LocAddZip = z1.zipcode AND z2.zipcode = $z AND ( 3963 * acos( truncate( sin( z2.lat / 57.2958 ) * sin( z1.lat / 57.2958 ) + cos( z2.lat / 57.2958 ) * cos( z1.lat / 57.2958 ) * cos( z1.long / 57.2958 - z2.long / 57.2958 ) , 8 ) ) ) <= $r ") or die(mysql_error()); while($row = mysql_fetch_array( $sql )) { $store = $row['MktName']."<br />"; $store .= $row['LocAddSt']."<br />"; $store .= $row['LocAddCity'].", ".$row['LocAddState']." ".$row['LocAddZip']; $lat1 = $row['lat']; $lon1 = $row['long']; $lat2 = $row['y1']; $lon2 = $row['x1']; $dis = distance($lat1, $lon1, $lat2, $lon2); echo "<p>".$store."</p>"; echo ceil($dis) . " mile(s) away"; echo "<hr/>"; } } ?> I get a timeout error sometimes, and sometimes I don't. Is it the form, or would it be on the server? Thanks in advance Code: [Select] <?php if (isset($_POST['checking'])) { echo $_POST['checking']; } if (isset($_POST['test'])) { echo $_POST['test']; } ?> <form id="testform2" action="testform.php" method="post"> <select name="checking" onchange="this.form.submit()"><option value="5">5</option><option value="6">6</option></select> <input type="text" name"test" id="test"> <a href="#" onclick="this.form.submit()">submit it!</a> </form> It works when I try to submit by selecting a new value from the dropdown box but when I try to click the link it won't display the text field value. That is a test case for a problem I m having in one of my codes. hello everyone, I have a php form, everything works, I do not carry any header() at the end of the form because I have to stay on the same page and because I feel it wipes out the message you sent the form successfully, but for this though if reloading the page shows me the popup asking me to resend the form. how can i solve? I found a function in js with replacestate but I saw that it doesn't work with mobile Safari. if ( window.history.replaceState ) { window.history.replaceState( null, null, window.location.href ); }
Hi, I want to submit a form using ajax ans jquery with two fields input text and file. Code: [Select] <script> $(document).ready( function() { $('#basicinfofrm').ajaxForm(function() { url: ''+PN+'.php', type:'POST', data:'action=yes&'+frmFeilds, success: function(html) { alert(html); } }).submit(); </script> <form action='' method='post'> <label>name</label> <input type='text' name='txtname' /> <input type='file' name = 'txtfile' /> <input type='submit' value='save' /> </form> but is is not working... can anyone tell me how to? i don't want to refresh my page Thanks |