PHP - Form Submit
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 Similar TutorialsSay 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 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> 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 have setup a basic enquiry form with a Captcha - once the code has been inserted and is correct I want to action the form (submit) in PHP. <?php session_start(); if($_SERVER['REQUEST_METHOD'] == 'POST'){ $vResult = ''; if(strtolower($_SESSION['security_code']) != strtolower($_POST['security_code'])){ $vResult = 'Invalid code!'; } else{ "/enquiry.php" } } ?> I want to submit the form to /enquiry.php - I tried header(Location.. and realised that just redirects, and doesn't submit the form. Any suggestions or tips would be great. Cheers, Paul I can't submit php form using IE 8. This works fine on Firefox very well. I tried following code but none of them is working. 1. <button type="submit">Submit</button> 2. <input type="submit" value="Submit" name="submit"> I would appreciate if any one help me in this. i have a form for my admin to update the products and their deails on my site. but i have decided to add stock and supplier tables to the database. so i have a products table, stock and supplier. each have an id.
in my admin form, id like the admin to submit once to multiple tables...
php code that i need to improve
<?php // Parse the form data and add inventory item to the system if (isset($_POST['product_name'])) { $product_name = $_POST['product_name']; $price = $_POST['price']; $category = $_POST['category']; $stock = $_POST['stock']; $details = $_POST['details']; $rating =$_POST['rating']; $letter = $_POST['letter']; $supplier = $_POST['supplier']; // See if that product name is an identical match to another product in the system $sql = mysqli_query($con, "SELECT id FROM products WHERE product_name='$product_name' LIMIT 1"); $productMatch = mysqli_num_rows($sql); // count the output amount //if product match is greater than 0 if ($productMatch > 0) { echo 'Sorry you tried to place a duplicate "Product Name" into the system, <a href="inventory_list.php">click here</a>'; exit(); } // Add this product into the database now by sql query $sql = mysqli_query($con, "INSERT INTO products (product_name, price, details, category, stock, letter, supplier, rating, date_added) VALUES('$product_name','$price','$details','$category', '$stock' ,'$letter',' $supplier' , '$rating' now())") or die (mysqli_error()); $pid = mysqli_insert_id($con); // Place image in the folder $newname = "$pid.jpg"; move_uploaded_file($_FILES['fileField']['tmp_name'], "../inventory_images/$newname"); //_FILES is a global var header("location: inventory_list.php"); //auto refresh, and it wont try to re add the item exit();//not necessary but its always safe to exit } ?> html form <form action="inventory_list.php" enctype="multipart/form-data" name="myForm" id="myForm" method="post"> <table width="95%" border="0" align="center" cellpadding="5" cellspacing="0" summary="this is where the admin will insert new items"> <caption><div id="title"><a id="add_new_item"></a>Add New Inventory Item</div> </caption> <tr > <th width="30%" scope="col" align="left">Product Image</th> <th width="70%"><label class="desc"> <input type="file" name="fileField" id="fileField" autofocus required /> </label></td> </tr> <tr > <th width="30%" scope="col" align="left">Product Name</th> <th width="70%" scope="col" align="left"> <label class="desc"> <input name="product_name" type="text" id="product_name" size="64" autofocus required /> </label></th> </tr> <tr> <th width="30%" scope="row" align="left">Letter</th> <td width="70%"> <label class="desc"> <input name="letter" type="text" id="letter" autofocus required /> </label></td> </tr> <tr> <th width="30%" scope="row" align="left">Product Price</th> <td width="70%"> <label class="desc"> <input name="price" type="text" id="price" autofocus required /> </label></td> </tr> <tr> <th width="30%" scope="row"align="left">Category</th> <td width="70%"><label class="desc"> <select name="category" id="category"> <option value="Fruits">Fruits</option> <option value="Vegetables">Vegetables</option> <option value="Indoor Plants">Indoor Plants</option> <option value="Outdoor Plants">Outdoor Plants</option> </select> </label></td> </tr> <tr> <th width="30%" scope="row" align="left">Suppliers</th> <td width="70%"> <label class="desc"> <select name="supplier" id="supplier"> <option value="Kenny's Organic Supplies">Kenny's Organic Supplies</option> <option value="Mom's Garden">Mom's Garden</option> <option value="Big Brother">Big Brother</option> </select> </label></td> </tr> <tr> <th width="30%" scope="row" align="left">Stock</th> <td width="70%"> <label class="desc"> <input name="stock" type="text" id="stock" autofocus required /> </label></td> </tr> <tr> <th width="30%" scope="row"align="left">Product Details</th> <td width="70%"><label class="desc"> <textarea name="details" id="details" cols="35" rows="5" autofocus required></textarea> </label></td> </tr> <tr> <th width="30%" scope="row" align="left">Rating</th> <td width="70%"><label class="desc"> <select name="rating" id="rating" > <option value="1">1 of 3 Stars</option> <option value="2">2 of 3 Stars</option> <option value="3">3 of 3 Stars</option> </select> </label></td> </tr> <tr> <th width="30%" scope="row"> </th> <td width="70%" align="right"><label class="desc"> <input type="submit" name="button" id="button" value="Add This Item Now" /> </label></td> </tr> <tr> <th width="30%" scope="row"> </th> <td width="70%"> </td> </tr> </table> </form> Edited by Ch0cu3r, 17 January 2015 - 04:03 PM. I have a Feedback form that I use to get peoples input. So far it works But I have 2 Problems Here is the Code: Code: [Select] <?php include "includes/config.php"; $date = date('jS \of F h:i A'); $sql="INSERT INTO news (name, email, comments, date) VALUES ('$_POST[Name]', '$_POST[email]', '$_POST[comments]', '$date')"; header( 'Location: thanks.php' ); mysql_close($con) ?> I'm making a VB.net Feedback form and I want to imput like this http://mysite.com/feedback.php?name=Mike&email=test@test.net&comments=comment&date=20th of April 12:30 AM But so far from my testing it doesn't register the values and says that there is a Duplicate value for email ". I'd like it to register values somehow and if there is a duplicate email entered then have it update it or write over it. Any help appreciated, Thanks! Been working on a xhtml website for university. Wanted to add a place where artists for hendohiphopshow.com could submit music. Did some research and came up with 'some' code. Not sure if it is close, or completely off. I have NO php experience. So any input/help would be a major help. http://www.hendohiphopshow.com/music_form.html http://www.hendohiphopshow.com/scripts/uploadmusic.php Thanks P.S. I have already handed this into Uni, I am developing this for my own use now. I have a form that is not doing anything after I click "submit". The code is below and a demo with the code is he http://communitycouch.com/index.php?action=register Code: [Select] <?php /* Things to do: Create error to show error when special characters are inputted in First and Last Name Fields Verify Dates to be true upon submit (for bithdays) Create birthday variable to be submitted into database, also add is_numberic() change activate.php to index?action=activate */ if($action == 'register') { if (isset($_POST['submit'])) { $errors = array(); require_once('connection.php'); //////////Checks Username //////////Makes sure username is 4-20 characters and contains only letters and numbers if(ereg("[[:alnum:]]{4,20}",stripslashes(trim($_POST['username'])))) { $user = mysql_real_escape_string($_POST['username']); $query = "SELECT username FROM reg_vars WHERE username = '$username'"; $result = @mysql_query($query); $num = @mysql_num_rows($result); if ($num> 0) { $errors[] = '<font color="red">The username you have chosen has already been taken, please try again.</font>'; } else { $username = mysql_real_escape_string($_POST['username']); } } else { $errors[] = '<font color="red">Please provide a valid username between 4 and 30 characters.</font>'; } //////////Checks E-mail if (!eregi('^[a-zA-Z]+[a-zA-Z0-9_-]*@([a-zA-Z0-9]+){1}(\.[a-zA-Z0-9]+){1,2}', stripslashes(trim($_POST['email'])) ) || empty($_POST['email'])) { $errors[] = '<font color="red">Please provide a valid email address.</font>'; } else { $email = mysql_real_escape_string($_POST['email']); } ///////// Check Names if (empty($f_name)) { $error["f_name"] = "First Name is blank."; } if (empty($l_name)) { $error["l_name"] = "Last Name is blank."; } ////////// Check PASSWORDS if (!empty($_POST['password'])) { if ($_POST['password'] != $_POST['cpassword']) { $errors[] = '<font color="red">The passwords you have entered do not match.</font>'; } else { $password = $_POST['password']; } } else { $errors[] = '<font color="red">Please provide a password.</font>'; } /////////Send Activation E-mail //////// Add Birthday to the registrarion Variables if (empty($errors)) { $a = md5(uniqid(rand(), true)); $query = "INSERT INTO reg_vars (username, f_name, l_name, email, password, active) VALUES ('$username', '$email', SHA1('$password'), '$a')"; $result = @mysql_query($query); if (mysql_affected_rows() == 1) { ////////// Send the Activation email $body = "Thank you for registering at the User Registration site. To activate your account, please click on this link:\n\n"; $body .= "http://www.communitycouch.com/activate.php?x=" . mysql_insert_id() . "&y=$a"; mail($_POST['email'], 'Registration Confirmation', $body, 'From: noreply@communitycouch.com'); ////////// Show thank you message echo '<h3>Thank You!</h3> You have been registered, you have been sent an e-mail to the address you specified before. Please check your e-mails to activate your account.'; } else { echo '<font color="red">You could not be registered, please contact us about the problem and we will fix it as soon as we can.</font>'; } } else { echo '<h3>Error!</h3> The following error(s) occured:<br />'; foreach ($errors as $msg) { echo " <div id=\"success_or_fail\"><font color=\"red\">$msg</font><br />\n</div>"; } } } echo " <div id=\"register_container\" class=\"Container\"> <div id=\"register_Center\" class=\"BoxCenter\"> "; echo" <div id=\"register_BoxContainer\" class=\"Container\"> <div class=\"HeaderLeft\"></div><div id=\"register_Header\" class=\"HeaderCenter\">Register for Community Couch</div><div class=\"HeaderRight\"></div><br /> <div id=\"register_Content\" class=\"BoxContent\"> <form name=\"reg_form\" action=\"";$_SERVER['PHP_SELF']; echo"\" method=\"post\" style=\"margin: 0;\"> <div class=\"Container FormBoxLeft\"> <b>Username:</b> </div> <div class=\"Container FormBoxRight\"> <input name=\"username\" size=\"30\" type=\"text\" /> </div> <br class=\"EndColumn\" /> <div class=\"Container FormBoxLeft\"> <b>First Name:</b> </div> <div class=\"Container FormBoxRight\"> <input name=\"f_name\" size=\"30\" type=\"text\" /> </div> <br class=\"EndColumn\" /> <div class=\"Container FormBoxLeft\"> <b>Last Name:</b> </div> <div class=\"Container FormBoxRight\"> <input name=\"l_name\" size=\"30\" type=\"text\" /> </div> <br class=\"EndColumn\" /> <div class=\"Container FormBoxLeft\"> <b>Birthdate:</b> </div> <div class=\"Container FormBoxRight\"> <select name=\"month\"><option value=\"\">-Month-</option> <option value=\"01\">January</option> <option value=\"02\">February</option> <option value=\"03\">March</option> <option value=\"04\">April</option> <option value=\"05\">May</option> <option value=\"06\">June</option> <option value=\"07\">July</option> <option value=\"08\">August</option> <option value=\"09\">September</option> <option value=\"10\">October</option> <option value=\"11\">November</option> <option value=\"12\">December</option> </select> <select name=\"day\"> <option value=\"\"> -Day-</option>'; //Print 31 Days "; for ($x=1; $x<=31; $x++) { echo "<option value='".$x."'"; if(isset($_POST['submit']) && $day == $x) { echo " selected"; } echo ">".$x."</option>\n"; } echo "</select> <input name=\"year\" size=\"2\" maxlength=\"4\" type=\"text\"> </div> <br class=\"EndColumn\" /> <div class=\"Container FormBoxLeft\"> <b>E-Mail:</b> </div> <div class=\"Container FormBoxRight\"> <input name=\"email\" size=\"30\" type=\"text\" /> </div> <br class=\"EndColumn\" /> <div class=\"Container FormBoxLeft\"> <b>Display E-Mail to the Public:</b> </div> <div class=\"Container FormBoxRight\"> <input name=\"disp_email\" value=\"yes\" type=\"radio\" /> Yes <input name=\"disp_email\" value=\"no\" type=\"radio\" checked /> No </div> <br class=\"EndColumn\" /> <div class=\"Container FormBoxLeft\"> <b>Password:</b> </div> <div class=\"Container FormBoxRight\"> <input name=\"password\" size=\"30\" type=\"password\" /> </div> <br class=\"EndColumn\" /> <div class=\"Container FormBoxLeft\"> <b>Confirm Password:</b> </div> <div class=\"Container FormBoxRight\"> <input name=\"cpassword\" size=\"30\" type=\"password\" /> </div> <br class=\"EndColumn\" /> <div id=\"register_submit\" class=\"Container\"> <input name=\"tos\" type=\"checkbox\" /> I have read and agree to the Terms of Use and Privacy Policy<br /> <input type=\"submit\" value=\"Submit\"><input type=\"reset\" value=\"Reset\"> </div> <br class=\"EndColumn\" /> </form> </div> <div class=\"FooterLeft\"></div><div id=\"register_Footer\" class=\"FooterCenter\"></div><div class=\"FooterRight\"></div> </div> </div> </div> <br class=\"EndColumn\" /> <br />"; }?> [\code] I have a form which people can submit information to and then creates a unique ID number. I then echo the form results onto another page. I also want to use the unique id within a link however it echos every id in the database and not just the unique id of the newly submitted form. For example, on 100th submit: For Submit: hello my name is Tom. Echo: $comment hello my name is Tom. $id 1009998979695949392919089................. Can anyone advise how I can get it so echo just the id number which refers to this submission. IE "hello my name is Tom" 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. I am fairly new to PHP forms so I am trying to adapt an example that I found online. Right now it IS functioning... showing a error message OR showing a success message and sending all the form information to my email account. I would like to edit it to redirect to a specific page if it has an error (http://www.mosaleen.com/contact_error.html) and to another if it sends successfully (http://www.mosaleen.com/thankyou_email.html) I am a bit confused by how the script is looped at the end. However, if I delete out that last few lines of coding, the form stops working. I am attaching the code below. Keep in mind that I am a newbie! Code: [Select] <?php // Turn on error reporting. Handy for debugging. error_reporting(E_ALL ^ E_NOTICE); // The following parameters are pretty much all that you // need to change except for the format of the email message // below. Note that your mail server may require the mailTo // address be in the host domain. $mailTo = "****"; // The address that will receive form submissions $mailSubject = "Comments from Mosaleen"; // Whatever you want $mailHost = "****"; // Usually looks like mail.yourhost.com $mailPort = "25"; // Usually 25 $mailAuth = true; // "true" if your mail server requires authentication, "false" if not $mailPassword = "****"; // The mail password associated with $mailTo // If you want to get cookies values... // $myCookie = $_COOKIE["cookiename"]; // Get the form fields. $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; // If there are errors, display them and a back button. if($errorMessages) { ?> <p>Errors were found on the form.</p> <ul> <?php echo $errorMessages; ?> </ul> <p><input type="button" value="Back" onClick="history.back()"></p> <?php } // No errors, send the message and print out success message. else { // These can sometimes be useful, although you should not // violate your site's privacy policy. $browser = $HTTP_USER_AGENT; $ip = $_SERVER['REMOTE_ADDR']; // Build the email.<br /> $body = " Name: $name Email: $email Phone: $phone Message: $message -------------------- Browser: $browser User IP: $ip"; include("Mail.php"); $headers["From"] = "contact@mosaleen.com"; $headers["To"] = $mailTo; $headers["Subject"] = $mailSubject; $params["host"] = $mailHost; $params["port"] = $mailPort; $params["auth"] = $mailAuth; $params["username"] = $mailTo; $params["password"] = $mailPassword; $mail_object =& Mail::factory("smtp", $params); $mail_object->send($mailTo, $headers, $body); ?> <h1>Thank You</h1> <p>Thank you for contacting us. We will be in touch with you shortly.</p> <?php } ?> I'm a bit new to PHP and I'm getting my feet wet with mvc with code igniter. I'm having a bit of trouble with my view accessing a function from my controller. If anyone has seen CodeIgniter from Scratch Day 4, it's that tutorial - i've created an email newsletter signup.
In my my view (newsletter.php), my submit button is not working and isn't able to access a function from my controller (email.php). The inaccessible function is called function send(). Instead, I get a 404 error. I'll post the code from both the view and controller, but I highly suspect the error is contained within the view because my controller loads the view, but my view can't call a function from the controller. Any help you can provide would be greatly appreciated. Thanks.
Here's the code from my view (newsletter.php):
<html lang='en'> Hello everyone, this is my first post here! My question covers a PHP, SQL, and HTML so I apologise if this isn't the appropriate section to post this message. Outline to my problem: A user can search my database for a variety of events, which are then listed on a results form. Next to each result I have an option to add this event to the users personal area as a 'saved event' for future reference. Currently I have a solution whereby an HTML form sends an action to '#', inserts the event ID and member ID into the 'savedevent' table via a PHP/SQL function. The page then displays 'event added'. THIS WORKS. However, if the user navigates away from the page, and then back to it again, the PHP script is obviously run again, ie- a 'resend data' dialog box is displayed to the user, which I really don't want. This website:http://www.bandsintown.com/event/3988178-nme-awards-tour-2011-london-united-kingdom-live-at-o2-academy-brixton-on-february-19-2011 achieves exactly what I am trying to do with the 'attending' button, but I cannot figure out how they accomplish this. Any help and ideas would be greatly appreciated. Hello again, and thanks! paddyfields. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=323588.0 |