PHP - Php Array Form Issues
Hello, Have the following form that takes data from the DB when u click on the text the left input increments when u click on it the same input decrement its value. Have 2 main issues now: 1- the value of the input fields needs to be set after the post is submitted and having issue with that since it's an array. 2-after the submit the post is saved in an array (the out is showing in the attched image), need to choose each related item , price and quantity like product 1 price 1 quantity 1 so i can update the db later on. All the Best <form method='POST' action=''> <?php if ($err1==0) { /*DB CODES...*/ $num_rows = mysqli_num_rows($sql_1); if (isset($_POST["form_Order"]) && $_POST["form_Order"] == "form_Order") { $orderID=clean_input($_POST["orderID"]); $cat_Code=$_POST["cat_Code"]; $sub_Cat_Code=$_POST["sub_Cat_Code"]; $array_Order = array($_POST); print_r ($array_Order)."<br>"; /*DB CODES...*/ $res_sql_1 = mysqli_query($connection, $sql_2); /*additional codes*/ }//end if $_POST while ($row_sql_Item = mysqli_fetch_assoc($res_sql_Item)) { $product_Name = $row_sql_Item["item"]; $product_Price = $row_sql_Item["price"]; $subCatCode=$row_sql_Item["sub_cat_code"]; if(isset($_POST['productName[]'])){ $productname=$_POST['productName[]'];}else{ $productname=$product_Name;} if(isset($_POST['product_Price[]'])){ $productPrice=$_POST['product_Price[]'];}else{ $productPrice=$product_Price;} echo "<div> <input type='number' min='0' max='10' name='quantity[]' value='"; if(isset($_POST['quantity']) && is_array($_POST['quantity'])){ $quantitiez = array(); foreach ($quantitiez as $quant){ print $quant; } }else{ echo "0";} echo "' onclick=\"this.parentNode.querySelector('input[type=number]').stepDown();this.form.submit();\" class='productQuantity' readonly> <input type='text' min='0' max='10' name='productName[]' value='$productname' onclick=\"this.parentNode.querySelector('input[type=number]').stepUp();this.form.submit();\" class='productName' readonly> <input type='text' name='product_Price[]' value='$productPrice' class='productPrice' onclick=\"this.form.submit()\" readonly> <input type='hidden' name='orderID' value='$orderID'> <input type='hidden' name='cat_Code' value='$catCode'> <input type='hidden' name='sub_Cat_Code' value='$subCatCode'> <input type='hidden' name='form_Order' value='form_Order'></div> "; }//end While }//end if $err1 ?> </form>
Similar Tutorialsi have two pages form and submit page index.php Code: [Select] <?php error_reporting(E_ALL); $bauturi = array('bauturi_alcoolice'=>'Bauturi alcoolice','sucuri'=>'Sucuri','bauturi_racoritoare'=>'Bauturi racoritoare'); echo '<form action="post.php" method="post">'; echo'<select name="bauturi">'; foreach($bauturi as $let=>$word){ echo'<option value="'.$let.'">'.$word.'</option>'; } echo'</select>'; echo '<INPUT type="submit" value="show me money"> </form>'; ?> post.php Code: [Select] <?php error_reporting(E_ALL); $drop = $_REQUEST['bauturi']; echo $drop; ?>if i select Bauturi alcoolice on post.php page i get bauturi_alcoolice but i want to get Bauturi alcoolice as result i tried to use foreach like this Code: [Select] <?php error_reporting(E_ALL); $drop = $_REQUEST['bauturi']; $bauturi = array('bauturi_alcoolice'=>'Bauturi alcoolice','sucuri'=>'Sucuri','bauturi_racoritoare'=>'Bauturi racoritoare'); foreach($bauturi as $drop=>$word){ echo $word; echo "<br/>"; unset($word); } ?> but i get all the values in the form i only want to show the selected value from the form in post.php page thanks in advance Hey, I'm editting some code on an OS Commerce install, For some reason I dont get the various buttons displaying. Underneath the shopping basket, it is supposed to show a view cart button and a checkout button, but they dont show up. I'm also trying to edit it to use a layout of the stylesheet, Basically if you look at my website, you will see the categories list, these are generated by an <ul><li> code, which puts the background underneath the item name, I would like to do the same thing and limit the charactors in the name to say 50 (so they stay on one line) Can you point me in the right direction to set an <li> on each item in the cart, and change it to UCWORDS, and restrict the charactors please? Any ideas on why the images dont show up on the page? http://tinyurl.com/2f6g2lg This is my code. <?php /* $Id: shopping_cart.php,v 1.18 2003/02/10 22:31:06 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ ?> <!-- shopping_cart //--> <?php // $info_box_contents = array(); // $info_box_contents[] = array('text' => BOX_HEADING_SHOPPING_CART); // new infoBoxHeading($info_box_contents, false, true, tep_href_link(FILENAME_SHOPPING_CART)); $cart_contents_string = ''; if ($cart->count_contents() > 0) { $cart_contents_string = '<table border="0" width="100%" cellspacing="0" cellpadding="0">'; $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $cart_contents_string .= '<tr><td align="right" valign="top" class="infoBoxContents">'; if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { $cart_contents_string .= '<span class="newItemInCart">'; } else { $cart_contents_string .= '<span class="infoBoxContents">'; } $cart_contents_string .= $products[$i]['quantity'] . ' x </span></td><td valign="top" class="infoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">'; if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { $cart_contents_string .= '<span class="newItemInCart">'; } else { $cart_contents_string .= '<span class="infoBoxContents">'; } $cart_contents_string .= $products[$i]['name'] . '</span></a></td></tr>'; if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { tep_session_unregister('new_products_id_in_cart'); } } $cart_contents_string .= '</table>'; } else { $cart_contents_string .= BOX_SHOPPING_CART_EMPTY; } $info_box_contents = array(); $info_box_contents[] = array('text' => $cart_contents_string); if ($cart->count_contents() > 0) { $info_box_contents[] = array('text' => tep_draw_separator()); $info_box_contents[] = array('align' => 'right', 'text' => $currencies->format($cart->show_total()) ); //cart buttons start $info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . tep_image_button ('button_cart_view.gif', IMAGE_BUTTON_CART_VIEW) . '</a>' . '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING) . '">' . tep_image_button ('button_cart_checkout.gif', IMAGE_BUTTON_CART_CHECKOUT) . '</a>' ); //cart buttons end } new infoBox($info_box_contents); ?> <!-- shopping_cart_eof //--> Thanks for taking the time to read the thread. Basically the situation is with the following code: Line 1: print(self::$internal_commands[$command_value]); Line 2: print(self::$internal_commands[":!modules"]); This will output the following: Code: [Select] Line 1: PHP Notice: Undefined index: :!modules in /var/www/html/MagicIRC/Framework/commands.class.php on line 36 Line 2: Commands_Framework::command_loadedmods Notice how the first notice tells you that ':!modules' isn't in the array yet the second print statement below it prints fine and the var $command_value is being supplied the same string as what the manually input print statement is? Hello all, What I'm trying to do is insert dynamic data supplied by the user into an array, but for some reason, the loop only builds arrays inside of arrays (or so it seems) and doesn't create an array with unique indexes and associated data. I was hoping someone could point me in the right path? I've searched numerous forums, threads and google but cannot find an answer. Here is the code snippet I'm working on. What it's supposed to do is collect a user's input, which is a Quantity amount and a high number, and based on that amount, create an array of random integers. This is my latest attempt. Now, maybe I'm just losing it, but when I place print_r($output) inside the loop, I see how it's being created but no unique indexes, just nested arrays. When I place it outside of the loop, I only receive one array with one index and value even though a high quantity was sent to the script. Code: [Select] $i = 1; while ($i <= $Quantity){ $output = array(rand($RandLow, $RandHigh)); $i++; } print_r($output); Here is another attempt, which again proved to be unsuccessful, at least to my tire brain. Code: [Select] $i = 1; while ($i <= $Quantity){ $output = rand($RandLow, $RandHigh); $total = array($output); $i++; } print_r($total); I've tried the for() loop as well but I just can't seem to make heads or tails of this and I'm sure it's going to be something simple that I'm missing. Thanks in advance for any help and insight if you know a better way to do this. hi i am trying to make a payroll calculator script that takes employee info, calculates pay, displays submitted info in a table, stores info in an array, and updates the array when new info is submitted. i have most of these accomplished, i am having trouble with the "store into an array, and update the array when new info is submitted" parts of the project. i am still not very fluent in php so there may be easier ways to achieve what i have so far. any pointers would be a great help, this part has got me stumped. Good evening, I'm having some issues with a PHP "contact us" script. I'm hoping there may be someone on the board that can shed some light on what is going on. The only recent change to the script is that the server was upgraded from PHP4 to PHP5. I'm not even sure if that is related, as I can't specifically identify that this issue started at the same time as that upgrade. The form is emailing, however the area where the fields should be displaying in the email message are all blank. Without further ado...here's the HTML page containing the form: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="Request additional information about Civil Air Patrol services offered, membership opportunities, or general questions."> <meta name="keywords" content="Civil Air Patrol. United States Air Force, Cadet Program, Aerospace Education, Cadet Programs" /> <meta name="author" content="http://www.squadron282.com" /> <link rel="stylesheet" type="text/css" media="screen,projection" href="./css/style_screen.css" /> <link rel="stylesheet" type="text/css" media="print" href="./css/style_print.css" /> <title>CIVIL AIR PATROL SQUADRON 282 - Contact Us</title> <style type="text/css"> <!-- .style1 { font-size: 14 } .style2 {font-size: 10px} .style12 {font-size: 12px} --> </style> </head> <body> <div class="page-container-1"> <!-- HEADER --> <!-- Flag navigations --> <!-- Navigation Level 1 --> <!-- Sitename --> <!-- Site slogan --> <!-- Header banner --> <div><img class="img-header" src="files/header6.jpg" alt="Wright Brothers 282nd Aero Composite Squadron - Civil Air Patrol"/></div> <!-- Navigation Level 2 --> <div class="nav2"> <ul> <li style="border-left: solid 1px rgb(54,83,151)"><a href="index.html" class="multi_line">GLR-OH-282 HOMEPAGE</a></li> <li><a href="missions.html" class="multi_line">SQUADRON MISSIONS</a></li> <li><a href="sqinfo.html" class="multi_line">SQUADRON INFO</a></li> <li><a href="sqmeetings.html" class="multi_line">SQUADRON MEETINGS</a></li> <li><a href="sqcalendar.html" class="multi_line">SQUADRON CALENDAR</a></li> <li><a href="membership.html" class="multi_line">SQUADRON MEMBERSHIP</a></li> <li><a href="commanderscorner.html" class="multi_line">SQUADRON COMMAND</a></li> <li><a href="gallery/main.php" class="multi_line">PHOTO GALLERY</a></li> <li><a href="contactus.html" class="selected multi_line">REQUEST MORE INFO</a></li> <li><a href="sitemappublic.html" class="multi_line"> WEBSITE MAP</a></li> </ul> </div> <!-- Buffer after header --> <div class="buffer"></div> <!-- NAVIGATION --> <!-- Navigation Level 3 --> <div class="nav3"> <ul> <li class="title">CONTACT US</li> <li class="group"><a href="contactus.html" class="selected">Contact Us</a></li> <li class="group"><a href="faqs.html">FAQ's</a></li> </ul> <!-- Print, Email, Bookmark Section --> <!-- ADDTHIS BUTTON BEGIN --> <div class="nav3"> <ul> <li class="title">SITE UTILITES</li> <center> <script type="text/javascript"> var addthis_config = { username: "CAPOH282" ui_cobrand: "CAP OH282" } </script> <div class="addthis_toolbox"> <div class="vertical"> <a class="addthis_button_email">Email</a> <a class="addthis_button_print">Print</a> <a class="addthis_button_favorites">Bookmark</a> <a class="addthis_button_twitter">Twitter</a> <a class="addthis_button_facebook">Facebook</a> <a class="addthis_button_myspace">MySpace</a> <a class="addthis_button_digg">Digg</a> <a class="addthis_button_expanded">More...</a> </div> </div> <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script> </center> </ul> </div> </div> <!-- ADDTHIS BUTTON END --> <!-- CONTENT --> <div class="content1"> <!-- Page title --> <div class="content1-pagetitle"> <p class="content-subtitle-noshade-size1 style1">CONTACT US<br /> </div> <div class="content1-container"> <table width="90%" border="0" align="center" cellpadding="0"> <tr> <td><form method="post" action="contactmailer.php"> <h2 align="justify">We would love to hear from you! If you are interested in what Civil Air Patrol has to offer, want to leave feedback on the website, or have questions, we are interested! Please feel free to call us at (937) 985-2820 or complete the form below and we will be glad to assist you in any way possible. For immediate answers to some of the most commonly asked questions, please check out our <a href="faqs.html">Frequently Asked Questions</a> page.</h2> <p align="justify">Please fill out as much of the following information as you care to share with us:</p> <table width="600" border="0" align="center" cellpadding="0"> <tr> <td width="250"><div align="left"> <h6>Name:</h6> </div></td> <td width="350"><div align="left"> <input type="text" name="name" size="40" /> </div></td> </tr> <tr> <td width="250"><div align="left"> <h6>Email:</h6> </div></td> <td width="350"><div align="left"> <input type="text" name="email" size="40" /> </div></td> </tr> <tr> <td width="250"><div align="left"> <h6>Address:</h6> </div></td> <td width="350"><div align="left"> <input type="text" name="address" size="40" /> </div></td> </tr> <tr> <td width="250"><div align="left"> <h6>City:</h6> </div></td> <td width="350"><div align="left"> <input type="text" name="city" size="40" /> </div></td> </tr> <tr> <td width="250"><div align="left"> <h6>State:</h6> </div></td> <td width="350"><div align="left"> <input name="state" type="text" size="4" maxlength="2" /> </div></td> </tr> <tr> <td width="250"><div align="left"> <h6>Zip:</h6> </div></td> <td width="350"><div align="left"> <input name="zip" type="text" size="7" maxlength="5" /> </div></td> </tr> <tr> <td width="250"><h6>Phone:</h6></td> <td width="350"><input name="phone" type="text" size="14" maxlength="12" /></td> </tr> <tr> <td width="250"><div align="left"> <h6>Time To Contact:</h6> </div></td> <td width="350"><div align="left"> <input type="text" name="timetocontact" size="40" /> </div></td> </tr> <tr align="left" valign="top"> <td width="250"><div align="left"> <h6> Program of Interest:</h6> </div></td> <td width="350"><p> <input type="checkbox" name="check[]" value="cadetprogram" /> Cadet Programs (Youth)<br /> <input type="checkbox" name="check[]" value="seniorprogram" /> Senior Programs (Adult)<br /> <input type="checkbox" name="check[]" value="patronprogram" /> Patron Membership<br /> <input type="checkbox" name="check[]" value="unsureonprogram" /> Unsure<br /> </p></td> </tr> <tr align="left" valign="top"> <td width="250"><div align="left"> <h6>Areas of Interest:<br /> (check all that apply)</h6> </div></td> <td width="350"><div align="left"> <p> <input type="checkbox" name="check[]" value="areaadmin" /> Administration<br /> <input type="checkbox" name="check[]" value="areaaerospace" /> <a href="missionsaerospace.html">Aerospace Education</a><br /> <input type="checkbox" name="check[]" value="areacadetprograms" /> <a href="missionscadet.html">Cadet Programs</a><br /> <input type="checkbox" name="check[]" value="areachaplain" /> Chaplain / Moral Leadership<br /> <input type="checkbox" name="check[]" value="areacommunications" /> <a href="missionses.html">Communications and Radios</a> <br /> <input type="checkbox" name="check[]" value="areadrillteam" /> Drill Team / Colorguard Activities<br /> <input type="checkbox" name="check[]" value="areaemergencyservices" /> <a href="missionses.html">Emergency Services / Search and Rescue</a><br /> <input type="checkbox" name="check[]" value="areaflightoperations" /> Flight Operations<br /> <input type="checkbox" name="check[]" value="areaphysicalfitness" /> Physical Fitness Training<br /> <input type="checkbox" name="check[]" value="arearecruiting" /> Public Affairs<br /> <input type="checkbox" name="check[]" value="areasafety" /> Safety<br /> <input type="checkbox" name="check[]" value="areaunsure" /> Unsure <br /> </p> </div></td> </tr> <tr> <td width="250" height="82" valign="middle"><h6>Comments:</h6></td> <td width="350"><p> <textarea name="comments" cols="50" rows="6"></textarea> </p></td> </tr> <tr> <td width="250"> <h6> <input type="submit" value="Submit Your Request" name="submit" /> </h6></td> <td width="350"> </td> </tr> </table> </form></td> </tr> </table> <p> </p> <p> </p> <!-- Nav Foorter --> <td height="55" valign="top"> <div align="center"> <p align="center"> <em><strong>PUBLIC INFORMATION</strong></em><br /> <a href="index.html">GLR-OH-282 HOMEPAGE</a> | <a href="missions.html">SQUADRON MISSIONS</a> | <a href="sqinfo.html">SQUADRON INFO</a> |<br /> <a href="sqmeetings.html">SQUADRON MEETINGS</a> | <a href="sqcalendar.html">SQUADRON CALENDAR</a> | <a href="membership.html">SQUADRON MEMBERSHIP</a> | <br /> <a href="commanderscorner.html">SQUADRON COMMAND</a> | <a href="/gallery/main.php">PHOTO GALLERY</a> | <a href="contactus.html">REQUEST MORE INFO</a> | <a href="sitemappublic.html">WEBSITE MAP</a><br /><br /> <em><strong>MEMBER RESOURCES</strong></em><br /> <a href="members.php">MEMBER RESOURCES</a> | <a href="resourcesaeroed.html">AEROSPACE EDUCATION</a> | <a href="resourceses.html">EMERGENCY SERVICES</a> | <br /> <a href="resourcescadet.html">CADET PROGRAMS</a> | <a href="resourcesofficer.html">OFFICER PROGRAM</a> | <a href="trainingnewmember.html">NEW MEMBERS</a> | <a href="resourcesuniforms.html">UNIFORM RESOURCES</a> |<br /> <a href="resourcesstaff.html">ADDITIONAL RESOURCES</a> | <a href="resourcesevents.html">ACTIVITY REGISTRATION</a> | <a href="sitemapmembers.html">WEBSITE MAP</a> </p> </div></td> </div> </div> <!-- SIDEBAR --> <!-- Empty sidebar: By adding "hide" to the class statement the sidebar becomes hidden --> <div class="sidebar hide"> </div> <!-- FOOTER --> <div class="footer"> <p><b>Copyright © 2010 Wright Brothers 282nd Aero Composite Squadron | All Rights Reserved</b></p> <p><span class="style12">LINKS OR REFERENCES TO INDIVIDUALS OR COMPANIES DOES NOT CONSTITUTE AN ENDORSEMENT OF ANY INFORMATION, <br />PRODUCT, OR SERVICE YOUR MAY RECEIVE FROM SUCH SOURCES. SITE MANAGED BY MAJ VECCHI. </span></p> </div> </div> </body> </html> And here is the PHP script that is driving the output: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><br> <html> <head> <title>CIVIL AIR PATROL - WRIGHT BROS 282ND AERO COMPOSITE SQUADRON</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php if(isset($_POST['submit'])) { $to = "cvecchi@squadron282.com"; $headers = 'From: CONTACT@SQUADRON282.COM' . "\r\n"; $subject = "Squadron282.com Contact Form"; $name_field = "$name"; $email_field = "$email"; $message = $_POST['message']; foreach($_POST['check'] as $value) { $check_msg .= "Checked: $value\n"; } $body = "Name: $name_field\n Email: $email_field\n Street: $address\n City: $city\n State: $state\n Zip: $zip\n Phone: $phone\n Time To Contact: $timetocontact\n $check_msg\n Comments: $comments\n"; echo "Your Information has been submitted to Squadron 282!"; mail($to, $subject, $body, $headers); } else { echo "There was an error in your submission, please resubmit."; } ?> <script language=javascript> setTimeout("location.href='contactthanks.html'", 0000); </script> </body> </html> If anyone could shed some light on this issue, I'd appreciate it! Thanks, Chris Ok, this is the situation, I have a form to email script installed on my website, (im not the best with PHP but im learning) I managed to adapt the main contact form to meet my needs however i am now having a few probs, basically the script i am using is IBDhost Contact Form. The basic code consits of 4 fields, name field, email field, subject dropdown box and message text box. On my site i need to adapt the form to incorporate additional fields, which are for the first form..... name field (compulsory), COMPANY name field (non compulsory), valid email (compulsory), contact number (compulsory), Department dropdown box ( i want this to determin what mailbox the message gets sent to, so rather than just 1 email address for all messages to go to, i want the user to determine where the email goes through a variety of email address options) and the main message text box. The second difference i need is for a different page, using the same form, but with different fields, Name field (compulsory), Contact Number (compulsory) email address (compulsory) message text box area(non compulsory) and an attachment upload field. I need the attachment upload to be able to do 1 of 2 things, either send the attachment along with the email, OR upload the email to a directory on my server BUT have the form details include a link to the form when i receive it. basically it will be used for C.V uploads for jobs. The code i am using is shown below ... FORM CODE: Code: [Select] <form method="post" action="sendeail.php"> <!-- DO NOT change ANY of the php sections --> <?php $ipi = getenv("REMOTE_ADDR"); $httprefi = getenv ("HTTP_REFERER"); $httpagenti = getenv ("HTTP_USER_AGENT"); ?> <input type="hidden" name="ip" value="<?php echo $ipi ?>" /> <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" /> <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /> Full Name: <br /> <input type="text" name="visitor" size="35" /> <br /> Valid Email:<br /> <input type="text" name="visitormail" size="35" /> <br /> Contact Number:<br /> <input type="text" name="visitorcontactnumber" size="35" /> <br /> <!-- BELOW IS WHERE I WANT THE USER TO BE ABLE TO PICK A DEPARTMENT BUT INSTEAD OF THAT BEING THE ATTENTION TO SUBJECT, I WANT IT TO SEND IT TO THE RELEVENT EMAIL ADDRESS --> Attention:<br /> <select name="attn" size="1"> <option value=" Administration ">Administration </option> <option value=" Existing Clients ">Clients (existing) </option> <option value=" New Client Enquiry ">Clients (new) </option> <option value=" Director Of Sales And Marketing ">Sales Director </option> <option value=" General Enquiries ">General Enquiries </option> <option value=" Site Support ">Site Support </option> <option value=" Recruitment ">Recruitment </option> <option value=" Web Master ">Webmaster </option> </select> <br /><br /> Message (please include company details if a client): <br /> <textarea name="notes" rows="6" cols="60"></textarea> <br /> <input type="submit" value="Send Mail" /> <br /> </form> SENDEAIL.php code Code: [Select] <?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $visitor = $_POST['visitor']; $visitormail = $_POST['visitormail']; $visitorcontactnumber = $_POST['visitorcontactnumber']; $attn = $_POST['attn']; $notes = $_POST['notes']; if (eregi('http:', $notes)) { die ("Do NOT try that! ! "); } if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) { echo "<h2>Use Back - Enter valid e-mail</h2>\n"; $badinput = "<h2>Your message was NOT submitted</h2>\n"; echo $badinput; die ("Go back! ! "); } if(empty($visitor) || empty($visitormail) || empty($visitorcontactnumber) || empty($notes )) { echo "<h2>Use Back - fill in all fields</h2>\n"; die ("Use back! ! "); } $todayis = date("l, F j, Y, g:i a") ; $attn = $attn ; $subject = $attn; $notes = stripcslashes($notes); $message = " $todayis [EST] \n Attention: $attn \n Message: $notes \n From: $visitor ($visitormail)\n Additional Info : IP = $ip \n Browser Info: $httpagent \n Referral : $httpref \n "; $from = "From: $visitormail\r\n"; mail("me@myemail.net", $subject, $message, $from, $visitorcontactnumber); ?> <p align="center"> Date: <?php echo $todayis ?> <br /> Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) <br /> Attention: <?php echo $attn ?> <br /> Message:<br /> <?php $notesout = str_replace("\r", "<br/>", $notes); echo $notesout; ?> <br /> <?php echo $ip ?> <br /><br /> <a href="contact.php"> Back </a> </p> the only problem i have with the form i have adapted so far is that all the details are coming through on the message to my email apart from the additional field (contact number) so im obviously missing something there as well. I would really appreciate any help. And i hope in the future i can assist someone on here too. Currently what I'm trying to do is to create a blogging software through PHP (for myself) and when trying to change the amount of posts viewable on the edit/delete page, the form, which auto-submits if JavaScript is enabled, should deliver the following result:
"/?page=EditPost&limit=6"
This is obviously depending on what value is chosen, it can be anywhere from 5 to 10. But what it is actually returning is "?limit=6".
This is the PHP script for the function:
public function EchoLimitSelector() { $limit = isset($_GET['limit']) ? $_GET['limit'] : NULL; echo "<div class='tright'>"; echo "<form action='?page=EditPost&limit=".$limit."' method='GET'>"; echo "<span>Posts per page: </span>"; echo "<select name='limit' style='font-size: 16px; width: 50px;' onchange='this.form.submit();'>"; for($x = 5; $x <= 10; $x++) { echo "<option value=".$x. " "; //Setting default selected value if($limit) { if($limit == $x) { echo "selected"; } } else { if($x == 5) { echo "selected"; } } echo ">".$x."</option>"; } echo "</select>"; echo "<noscript><input type='submit' value='Go' style='height: 26px; padding: 0; margin-top: -7px;'/></noscript>"; echo "</form>"; echo "</div>"; }I'm hoping that it's just a simple fix. Thanks. Hello there.new member here in need of help! So i use the code the code below to display images from a folder into a form. My problem is that i put checkboxes with various selections in order to transfer the selected items later to a file or echo the submission. As it seems at the moment is that i can display correctly everything in my form but for some unknown reason i cannot echo/write to a txt file the files(names) that i choose with the checkbox.There seems to be something wrong with my loop but i'm not sure. I would appreciate any help.thank you in advance. Here is my code: <?php SESSION_START(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="author" content="vs" /> <meta name="robots" content="index, follow" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> <link rel="stylesheet" type="text/css" href="print.css" media="print" /> <link rel="stylesheet" href="lightbox.css" type="text/css" media="screen" /> <script type="text/javascript" src="js/prototype.js"></script> <script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script> <script type="text/javascript" src="js/lightbox.js"></script> <title></title> </head> <body> <div id="centerColumn"> <div id="header"> </div><!--//end #headern//--> <div id="navbar"> <ul> <li><a href="index.html" title="Home">Home</a></li> <li><a href="about.html" title="About us">About us</a></li> <li><a href="gallery.html" title="Gallery">Gallery</a></li> <li><a href="contact.html" title="Contact">Contact</a></li> </ul> </div><!--//end #nav//--> <?php echo '<h2 class="medium"><i>Hello '.$_SESSION['user'].'</i></h2>'; ?> <p><span class="small"></span><br /> This is your private directory. Please submit your selections and fill in the contact form, thank you. </p><br> <div align="center"> <form method="post" action="data2file.php"> <?php echo '<div STYLE="overflow: auto; width: 780px; height: 600px; border-left: 5px gray solid; border-bottom: 5px gray solid; border-top: 5px gray solid; border-right: 5px gray solid;; padding: 0px; margin: 0px";> <table border="1" cellspacing=0 cellpadding=1> <tr><td>'; $username = $_SESSION['user']; $url = $username."/"; $handle = opendir ($url); while (false !== ($file = readdir($handle))) { if($file != "." && $file != ".." && $file != basename(__FILE__)) { //echo '<table border=1><tr><td>'; echo '<a href="'.$url.$file.'" rel="lightbox"><img border=1 src="'.$url.$file.'"></a>'; echo '<br />'; echo "<input type=CHECKBOX name=$file>"; print $file; echo '<br>'; echo '<select name=color> <option>Select Color Format...</option> <option> Sepia </option> <option> Black & White </option> </select>'; echo '<br> <select name=size> <option>Select Size Format...</option> <option name=5x7> 5" x 7"(13x19 cm)</option> <option name=6x8> 6" x 8"(15x21 cm)</option> <option name=8x12> 8" x 12"(20x30 cm) </option> <option name=9x14> 9" x 14"(24x30 cm) </option> <option name=12x18> 12" x 18"(30x40 cm) </option> </select>'; echo '<br>Reprints <input type="text" name="reprints" size="1" value="0"><br />'; echo '<hr>'; //echo '</td></tr></table>'; } } echo '</td></div>'; echo ' <td valign="top"> <p>*First name, Last name, Country, Home Address, Postal code and email fields are required*</p> <input type="text" name="first" value="First Name" size="35"/><br> <input type="text" name="last" value="Last Name" size="35"/><br> <select name="country"> <option value=" " selected>(please select a country)</option> <option value="AF">Afghanistan</option> <option value="AL">Albania</option> <option value="DZ">Algeria</option> <option value="AS">American Samoa</option> <option value="AD">Andorra</option> <option value="AO">Angola</option> <option value="AI">Anguilla</option> <option value="AQ">Antarctica</option> <option value="AG">Antigua and Barbuda</option> <option value="AR">Argentina</option> <option value="AM">Armenia</option> <option value="AW">Aruba</option> <option value="AU">Australia</option> <option value="AT">Austria</option> <option value="AZ">Azerbaijan</option> <option value="BS">Bahamas</option> <option value="BH">Bahrain</option> <option value="BD">Bangladesh</option> <option value="BB">Barbados</option> <option value="BY">Belarus</option> <option value="BE">Belgium</option> <option value="BZ">Belize</option> <option value="BJ">Benin</option> <option value="BM">Bermuda</option> <option value="BT">Bhutan</option> <option value="BO">Bolivia</option> <option value="BA">Bosnia and Herzegowina</option>echo <option value="BW">Botswana</option> <option value="BV">Bouvet Island</option> <option value="BR">Brazil</option> <option value="IO">British Indian Ocean Territory</option> <option value="BN">Brunei Darussalam</option> <option value="BG">Bulgaria</option> <option value="BF">Burkina Faso</option> <option value="BI">Burundi</option> <option value="KH">Cambodia</option> <option value="CM">Cameroon</option> <option value="CA">Canada</option> <option value="CV">Cape Verde</option> <option value="KY">Cayman Islands</option> <option value="CF">Central African Republic</option> <option value="TD">Chad</option> <option value="CL">Chile</option> <option value="CN">China</option> <option value="CX">Christmas Island</option> <option value="CC">Cocos (Keeling) Islands</option> <option value="CO">Colombia</option> <option value="KM">Comoros</option> <option value="CG">Congo</option> <option value="CD">Congo, the Democratic Republic of the</option> <option value="CK">Cook Islands</option> <option value="CR">Costa Rica</option> <option value="CI">Cote dIvoire</option> <option value="HR">Croatia (Hrvatska)</option> <option value="CU">Cuba</option> <option value="CY">Cyprus</option> <option value="CZ">Czech Republic</option> <option value="DK">Denmark</option> <option value="DJ">Djibouti</option> <option value="DM">Dominica</option> <option value="DO">Dominican Republic</option> <option value="TP">East Timor</option> <option value="EC">Ecuador</option> <option value="EG">Egypt</option> <option value="SV">El Salvador</option> <option value="GQ">Equatorial Guinea</option> <option value="ER">Eritrea</option> <option value="EE">Estonia</option> <option value="ET">Ethiopia</option> <option value="FK">Falkland Islands (Malvinas)</option> <option value="FO">Faroe Islands</option> <option value="FJ">Fiji</option> <option value="FI">Finland</option> <option value="FR">France</option> <option value="FX">France, Metropolitan</option> <option value="GF">French Guiana</option> <option value="PF">French Polynesia</option> <option value="TF">French Southern Territories</option> <option value="GA">Gabon</option> <option value="GM">Gambia</option> <option value="GE">Georgia</option> <option value="DE">Germany</option> <option value="GH">Ghana</option> <option value="GI">Gibraltar</option> <option value="GR">Greece</option> <option value="GL">Greenland</option> <option value="GD">Grenada</option> <option value="GP">Guadeloupe</option> <option value="GU">Guam</option> <option value="GT">Guatemala</option> <option value="GN">Guinea</option> <option value="GW">Guinea-Bissau</option> <option value="GY">Guyana</option> <option value="HT">Haiti</option> <option value="HM">Heard and Mc Donald Islands</option> <option value="VA">Holy See (Vatican City State)</option> <option value="HN">Honduras</option> <option value="HK">Hong Kong</option> <option value="HU">Hungary</option> <option value="IS">Iceland</option> <option value="IN">India</option> <option value="ID">Indonesia</option> <option value="IR">Iran (Islamic Republic of)</option> <option value="IQ">Iraq</option> <option value="IE">Ireland</option> <option value="IL">Israel</option> <option value="IT">Italy</option> <option value="JM">Jamaica</option> <option value="JP">Japan</option> <option value="JO">Jordan</option> <option value="KZ">Kazakhstan</option> <option value="KE">Kenya</option> <option value="KI">Kiribati</option> <option value="KP">Korea, Democratic Peoples Republic of</option> <option value="KR">Korea, Republic of</option> <option value="KW">Kuwait</option> <option value="KG">Kyrgyzstan</option> <option value="LA">Lao Peoples Democratic Republic</option> <option value="LV">Latvia</option> <option value="LB">Lebanon</option> <option value="LS">Lesotho</option> <option value="LR">Liberia</option> <option value="LY">Libyan Arab Jamahiriya</option> <option value="LI">Liechtenstein</option> <option value="LT">Lithuania</option> <option value="LU">Luxembourg</option> <option value="MO">Macau</option> <option value="MK">Macedonia, The Former Yugoslav Republic of</option> <option value="MG">Madagascar</option> <option value="MW">Malawi</option> <option value="MY">Malaysia</option> <option value="MV">Maldives</option> <option value="ML">Mali</option> <option value="MT">Malta</option> <option value="MH">Marshall Islands</option> <option value="MQ">Martinique</option> <option value="MR">Mauritania</option> <option value="MU">Mauritius</option> <option value="YT">Mayotte</option> <option value="MX">Mexico</option> <option value="FM">Micronesia, Federated States of</option> <option value="MD">Moldova, Republic of</option> <option value="MC">Monaco</option> <option value="MN">Mongolia</option> <option value="MS">Montserrat</option> <option value="MA">Morocco</option> <option value="MZ">Mozambique</option> <option value="MM">Myanmar</option> <option value="NA">Namibia</option> <option value="NR">Nauru</option> <option value="NP">Nepal</option> <option value="NL">Netherlands</option> <option value="AN">Netherlands Antilles</option> <option value="NC">New Caledonia</option> <option value="NZ">New Zealand</option> <option value="NI">Nicaragua</option> <option value="NE">Niger</option> <option value="NG">Nigeria</option> <option value="NU">Niue</option> <option value="NF">Norfolk Island</option> <option value="MP">Northern Mariana Islands</option> <option value="NO">Norway</option> <option value="OM">Oman</option> <option value="PK">Pakistan</option> <option value="PW">Palau</option> <option value="PA">Panama</option> <option value="PG">Papua New Guinea</option> <option value="PY">Paraguay</option> <option value="PE">Peru</option> <option value="PH">Philippines</option> <option value="PN">Pitcairn</option> <option value="PL">Poland</option> <option value="PT">Portugal</option> <option value="PR">Puerto Rico</option> <option value="QA">Qatar</option> <option value="RE">Reunion</option> <option value="RO">Romania</option> <option value="RU">Russian Federation</option> <option value="RW">Rwanda</option> <option value="KN">Saint Kitts and Nevis</option> <option value="LC">Saint LUCIA</option> <option value="VC">Saint Vincent and the Grenadines</option> <option value="WS">Samoa</option> <option value="SM">San Marino</option> <option value="ST">Sao Tome and Principe</option> <option value="SA">Saudi Arabia</option> <option value="SN">Senegal</option> <option value="SC">Seychelles</option> <option value="SL">Sierra Leone</option> <option value="SG">Singapore</option> <option value="SK">Slovakia (Slovak Republic)</option> <option value="SI">Slovenia</option> <option value="SB">Solomon Islands</option> <option value="SO">Somalia</option> <option value="ZA">South Africa</option> <option value="GS">South Georgia and the South Sandwich Islands</option> <option value="ES">Spain</option> <option value="LK">Sri Lanka</option> <option value="SH">St. Helena</option> <option value="PM">St. Pierre and Miquelon</option> <option value="SD">Sudan</option> <option value="SR">Suriname</option> <option value="SJ">Svalbard and Jan Mayen Islands</option> <option value="SZ">Swaziland</option> <option value="SE">Sweden</option> <option value="CH">Switzerland</option> <option value="SY">Syrian Arab Republic</option> <option value="TW">Taiwan, Province of China</option> <option value="TJ">Tajikistan</option> <option value="TZ">Tanzania, United Republic of</option> <option value="TH">Thailand</option> <option value="TG">Togo</option> <option value="TK">Tokelau</option> <option value="TO">Tonga</option> <option value="TT">Trinidad and Tobago</option> <option value="TN">Tunisia</option> <option value="TR">Turkey</option> <option value="TM">Turkmenistan</option> <option value="TC">Turks and Caicos Islands</option> <option value="TV">Tuvalu</option> <option value="UG">Uganda</option> <option value="UA">Ukraine</option> <option value="AE">United Arab Emirates</option> <option value="GB">United Kingdom</option> <option value="US">United States</option> <option value="UM">United States Minor Outlying Islands</option> <option value="UY">Uruguay</option> <option value="UZ">Uzbekistan</option> <option value="VU">Vanuatu</option> <option value="VE">Venezuela</option> <option value="VN">Viet Nam</option> <option value="VG">Virgin Islands (British)</option> <option value="VI">Virgin Islands (U.S.)</option> <option value="WF">Wallis and Futuna Islands</option> <option value="EH">Western Sahara</option> <option value="YE">Yemen</option> <option value="YU">Yugoslavia</option> <option value="ZM">Zambia</option> <option value="ZW">Zimbabwe</option> </select> <input type="text" name="address" value="Home Address" size="45"> <input type="text" name="address" value="Postal Code" size="35" <input type="text" name="email" value="e-mail" size="35"/><br> <input type="text" name="date" value="Wedding Date (dd-mm-yyyy)" size="35"/><br> <input type="text" name="time" value="Wedding Time (hh:mm)"/><br> <input type="text" name="hotel" value="Hotel" size="35"/><br> <input type="text" name="room" value="Room Number" size="10"/><br> <hr> <TEXTAREA NAME="comments" ROWS=10 COLS=45 value="Comments">Notes / Comments </TEXTAREA><br> </td></tr> </table>'; echo '</div> <br> <input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Reset"> <a href="logout.php"><input type="button" name="logout" value="Logout"></form></a> </div> <br>'; ?> <div id="footer"> <a href="http://validator.w3.org/" title="W3C HTML Validation">XHTML</a> . <a href="http://jigsaw.w3.org/css-validator/validator-uri.html" title="W3C CSS Validation">CSS</a> . <a href="http://www.w3.org/TR/WCAG10/" title="Web Content Accessibility Guidelines">WCAG</a> . <a href="http://www.csstinderbox.com">The CSS Tinderbox</a></div> <div align="center" class="boxes"> <!--//end #footer//--><small> ©2009-2010</small></div> </div> <!--//end #centerColumn//--> <!--width=256 height=170--> </body> </html> and here is the process to file code: <?php SESSION_START(); $arxeio = "data.txt"; $fp = fopen($arxeio, "a") or die("Couldn't open $arxeio for writing!"); //fwrite($fp, $_POST[$file]."\n"); fwrite($fp, $_POST['color']."\n") or die("Couldn't write values to file!"); fwrite($fp, $_POST['size']."\n"); fclose($fp); echo $_SESSION['user']; echo $_POST['color']; echo $_POST['country']; echo "Saved to $arxeio successfully!"; ?> How should i make my code to work only for the selected items along with their attributes. Thank you very much. Hi: I have few small issues with a Contact Us form I am putting together. 1 - When quotes or apostrophes are added to the input fields, they get turned into '\ (slashes). The "myCodeLib.php" file has a function to remove the slashes. I use it in the same way in the admin area and it works fine, so I don't see what I am missing: Code: [Select] <?php //STRIP SLASHES if(get_magic_quotes_gpc()) { $_POST = array_map('stripslashes',$_POST); $_GET = array_map('stripslashes',$_GET); $_COOKIE = array_map('stripslashes',$_COOKIE); } ?> 2 - A small issuse, but the Email validation doesn't seem to work entirely. It will accept a single character (like an "a") as valid, but it looks like it's suppose to check for a format like "a@a.com" 3 - How can I properly SPAN this code that write out the error: Code: [Select] echo $error; I want to do Code: [Select] <span class="textError">echo $error;</span> to make it red but I keep getting a snytax error This is the full code: Code: [Select] include('include/myConn.php'); include('include/myCodeLib.php'); <?php $error = NULL; $myDate = NULL; $FullName = NULL; $Address = NULL; $City = NULL; $State = NULL; $Zip = NULL; $Phone = NULL; $Email = NULL; $Website = NULL; $Comments = NULL; if(isset($_POST['submit'])) { $myDate = $_POST['myDate']; $FullName = $_POST['FullName']; $Address = $_POST['Address']; $City = $_POST['City']; $State = $_POST['State']; $Zip = $_POST['Zip']; $Phone = $_POST['Phone']; $Email = $_POST['Email']; $Website = $_POST['Website']; $Comments = $_POST['Comments']; if(empty($FullName)) { $error .= '-- Enter your Full Name. <br />'; } if(empty($Email) || preg_match('~^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$~',$Email)) { //<- if email is empty, or doesn't follow the expression. $error .= '-- Enter your Email. <br />'; //<- this is the error message. } if($error == NULL) { $sql = sprintf("INSERT INTO myContactData(myDate,FullName,Address,City,State,Zip,Phone,Email,Website,Comments) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s')", //<-database structure must be right. mysql_real_escape_string($myDate), mysql_real_escape_string($FullName), mysql_real_escape_string($Address), mysql_real_escape_string($City), mysql_real_escape_string($State), mysql_real_escape_string($Zip), mysql_real_escape_string($Phone), mysql_real_escape_string($Email), mysql_real_escape_string($Website), mysql_real_escape_string($Comments)); if(mysql_query($sql)) { $error .= 'Thank you for your comment!'; } else { $error .= 'There was an error in our Database, please Try again!'; } } } echo $error; $myDate = $_REQUEST['myDate'] ; $FullName = $_REQUEST['FullName'] ; $Address = $_REQUEST['Address'] ; $City = $_REQUEST['City'] ; $State = $_REQUEST['State'] ; $Zip = $_REQUEST['Zip'] ; $Phone = $_REQUEST['Phone'] ; $Email = $_REQUEST['Email'] ; $Website = $_REQUEST['Website'] ; $Comments = $_REQUEST['Comments'] ; mail( "email@website.com", "Contact Request", "Date Sent: $myDate\nFull Name: $FullName\nAddress: $Address\n City: $City\n State: $State\n Zip: $Zip\n Phone: $Phone\n Email: $Email\n Website: $Website\n Comments: $Comments\n", "From: $Email" ); ?> <form name="myform" action="" method="post"> <input type="hidden" name="myDate" size="45" maxlength="50" value="<?php echo date("F j, Y"); ?>" /> <div id="tableFormDiv"> <fieldset><span class="floatLeftFormWidth"><span class="textErrorItalic">* - Required</span></span> <span class="floatFormLeft"> </span></fieldset> <fieldset><span class="floatLeftFormWidth"><span class="textErrorItalic">*</span> Full Name:</span> <span class="floatFormLeft"><input type="text" name="FullName" size="45" maxlength="50" value="<?php echo $FullName; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Address:</span> <span class="floatFormLeft"><input type="text" name="Address" size="45" maxlength="50" value="<?php echo $Address; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">City:</span> <span class="floatFormLeft"><input type="text" name="City" size="45" maxlength="50" value="<?php echo $City; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">State:</span> <span class="floatFormLeft"><input type="text" name="State" size="45" maxlength="50" value="<?php echo $State; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Zip:</span> <span class="floatFormLeft"><input type="text" name="Zip" size="45" maxlength="50" value="<?php echo $Zip; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Phone:</span> <span class="floatFormLeft"><input type="text" name="Phone" size="45" maxlength="50" value="<?php echo $Phone; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth"><span class="textErrorItalic">*</span> Email:</span> <span class="floatFormLeft"><input type="text" name="Email" size="45" maxlength="50" value="<?php echo $Email; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Website:</span> <span class="floatFormLeft"><input type="text" name="Website" size="45" maxlength="50" value="<?php echo $Website; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Comments:</span> <span class="floatFormLeft"><textarea name="Comments" cols="40" rows="10"><?php echo $Comments; ?></textarea></span></fieldset> </div> <input type="submit" name="submit" value="Submit" class="submitButton" /><br /> </form> </div> Can someone please help me with this... My problem could be odd if say it but i will spill it out, only don't say I am mad completely jut a bit ! 1.when comment is first in whole news if i press edit appear html form but if i am trying to submit any information it returns to comments and don't update ! 2.if there were more than one comment in news if i press edit appear html forms 1.not working | 2.working and do updates | 3.were appear but is gone but not sure does bug will return also not working ! Sample how it looks ! This is indeed odd hope somebody has knowledge in such issues or at least a cure for such severe bug website http://hostings.flush.ws/ user guest password guest11 | to test bug go to the news comments and spam as much needed ! Link to edit code Code: [Select] echo "<a href='/?section=nwcomment&id=".$id."&comment=edit&id_edit=".$row_news_comment['hosting_comment_id']."'>Edit Comment</a>"; Update code as far i know it is correct at least i do hope sow (also this code is inside while cycle ) Code: [Select] if ($_GET['comment'] == 'edit') { $comment_id_edit = (INT)$_GET['id_edit']; $comment_text = $row_news_comment['hosting_comment_text']; $edit_comment_text = $_POST['hosting_comment_text']; if(isset($_POST['hosting_comment_text'])) { mysql_query("UPDATE hosting_comment SET hosting_comment_text = '".$edit_comment_text."' WHERE hosting_comment_id = '".$comment_id_edit."' ") or die (mysql_error()); } if (isset($_POST['Submit'])) { echo "<meta http-equiv='REFRESH' content='0;url=/?section=nwcomment&id=".$id."'>"; } echo ("<form action='/?section=nwcomment&id=".$id."&comment=edit&id_edit=".$comment_id_edit."'' id='edit_comment' name='edit_comment' method='post'> <p> <textarea name='hosting_comment_text' cols='50' rows='10' id='textarea' value='$edit_comment_text' ></textarea> <p> <input type='submit' name='Submit' id='button' value='{$lang['BODY_NEWS_COMMENT_SUBMIT']}' /> <input type='reset' name='Reset' id='button' value='{$lang['BODY_NEWS_COMMENT_RESET']}' /> </p> </form>"); } if is needed more complete code just ask i will publish it (i hope to fix bug as soon possible grand opening of registration will be on the Aprils Fools Day) Hello everyone. I'm trying to learn php here on the fly because i've been tasked with moving an existing internal website to a new server because the old one is failing fast. The failing server is very old and running a much older version of php. This form when submitted should send an email but the submit button doesn't even show when running the form on the new server. Also, right now all the text fields are showing the VALUE= value. I notice if I remove VALUE= from each part that removes the text but I'm not sure if that's the proper way to fix it.
Also, after the "Please wait for confirmation..." message, there is one text box prepopulated with \"ds\", then one below it with \"Click, then it appears to dump the rest of the code after </FORM> up to the last ?> onto the webpage as text.
I'm guessing some coding methods changed between php4 and whatever the newest version of php is that comes with a fresh linux server install. Can anyone offer any tips or fixes? Thanks in advance.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Update My Phone Number</title> </head> <body bgcolor="White" > <table width="640"> <tr><td><hr width="640" size="2" color="Red" align="left"></td></tr> <tr><td align="left"><font size="+3"><strong>Update Employee Telephone Numbers</strong></font></td></tr> <tr><td><hr width="640" size="2" color="gray" align="left"></td></tr> </table> <br> <? $form_block = " <FORM METHOD=\"post\" ACTION=\"$PHP_SELF\"> <p><strong>Employee name: <font size=\"-1\"><em>(Exactly as it should be listed)</em></font> <font color=\"#FF0000\">**Required</font></strong><br> <INPUT TYPE=\"text\" NAME=\"employee\" VALUE=\"$employee\" SIZE=\"75\" MAXLENGTH=\"100\"></p> <p><strong>Department: <font size=\"-1\"><em>(Exactly as it should be listed)</em></font> <font color=\"#FF0000\">**Required</font></strong><br> <INPUT TYPE=\"text\" NAME=\"department\" VALUE=\"$department\" SIZE=\"75\" MAXLENGTH=\"50\"></p> <p><strong>Work Phone Number <font color=\"#FF0000\">**Required</font></strong><br> <INPUT TYPE=\"text\" NAME=\"work\" VALUE=\"$work\" SIZE=\"15\" MAXLENGTH=\"15\"></p> <p><strong>Cell Phone Number <font color=\"#FF0000\">**Required -- enter \"na\" for not applicable</font></strong><br> <INPUT TYPE=\"text\" NAME=\"cell\" VALUE=\"$cell\" SIZE=\"15\" MAXLENGTH=\"15\"></p> <p><strong>Home Phone Number <font color=\"#FF0000\">**Required -- enter \"na\" for not applicable</font></strong><br> <INPUT type=\"text\" Name=\"home\" VALUE=\"$home\" SIZE=15 \" MAXLENGTH=\"15\"> </p> <p><strong>Pager Number <font color=\"#FF0000\">**Leave blank if you don't have a pager</font></strong><br> <INPUT type=\"text\" Name=\"pager\" VALUE=\"$pager\" SIZE=15 MAXLENGTH=\"15\"> </p> <p><strong>Comments:</strong><br> <TEXTAREA NAME=\"message\" ROWS=5 COLS=50 WRAP=virtual>$message</TEXTAREA></p> <br> <p><em>Please wait for confirmation - this may take a few seconds.</em></p> <INPUT type=\"hidden\" name=\"op\" value=\"ds\"> <p><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Click here to send this report\"></p> <br> </FORM> "; if ($op != "ds") { //they need to see the form echo "$form_block"; } else if ($op == "ds") { if ($employee == "") { $employee_err = "<font color=red>Please enter employee name! **REQUIRED</font><br>"; $send = "no"; } if ($department == "") { $department_err = "<font color=red>Please enter your department! **REQUIRED</font><br>"; $send = "no"; } if ($work == "") { $work_err = "<font color=red>Please enter your work phone! **REQUIRED</font><br>"; $send = "no"; } if ($cell == "") { $cell_err = "<font color=red>Please enter your cell phone! ** REQUIRED, enter \"na\" for not applicable</font><br>"; $send = "no"; } if ($home == "") { $home_err = "<font color=red>Please enter your home phone! *REQUIRED, enter \"na\" for not applicable!</font><br>"; $send = "no"; } if ($send != "no") { // it's okay to send $msg = "Please update the following phone numbers for: \t$employee\n\n"; $msg .= "Employee name:\t$employee\n\n"; $msg .= "Department:\t$department\n\n"; $msg .= "Work:\t$work\n\n"; $msg .= "Cell:\t$cell\n\n"; $msg .= "Home:\t$home\n\n"; $msg .= "Pager:\t$pager\n\n"; $msg .= "Comments:\t$message\n\n"; $to = "me@me.com"; $subject = "Phone Update: \t$employee, - \t$department\n"; $mailheaders = "From: UpdateMyPhone\n\n"; mail($to, $subject, $msg, $mailheaders); echo "<h1><font color=blue>Thank you! Your phone update has been filed. </font></h1><br> $form_block "; } else if ($send == "no") { echo "$employee_err"; echo "$department_err"; echo "$work_err"; echo "$cell_err"; echo "$home_err"; echo "$pager_err"; echo "$message_err"; echo "$form_block"; } } ?> </body> </html> I've created a quotation form and some of the values are passed in an array (i've used jQuery to clone the form for necessary fields). I currently have the following: foreach ($_GET as $var => $value) { // Stick POST names into "$var" and the values into "$value" if(!is_array($value)) { // Test us $value contains and array (horse detials are an array everything else isn't) echo "<strong>$var:</strong> $value<br />\n"; // Echo out the customer detials and additional information } else { // If the value is an array.... } } } But i'm kind of stuck for ideas on how to echo out the rest of the details in the way i need it... There are 6 arrays, I know I can do something like: $array = $_GET['quote-details']; foreach($array as $detail) { echo "<strong>Detail:</strong> $detail<br />\n"; } But I have to do this 6 times... I also want to sort these details in a logical manor, but again im a little stuck. So instead of it exporting like: Detail1 Detail1 Detail1 Detail2 Detail2 Detail2 etc, I want it to export as: Detail1 Detail2 Detail1 Detail2 If anyone can give me any help I would be VERY grateful! Regards, Mundo Hello! Hi, I have a Comma Delimited File called "houses.txt" with the contents of: HA11QS, 200, house1.jpg, 4 HA22BR, 280, house2.jpg, 10 HA33AB, 390, house3.jpg, 3 HA44CD, 320, house4.jpg, 8 I have a web form "form2.html": Code: [Select] <html> <head> <title>Untitled Document</title> </head> <body> <form action="any.php" method="post"> Please Enter Anything <input type="text" name="any"> <input type="submit" value="Submit"> </form> </body> </html> and PHP code of "any.php": <?php if (isset($_POST['any'])) { $filename = "houses.txt"; $fileOpen = fopen($filename, "r"); $max = $_POST['any']; $rowsArr = file ($filename); foreach ($rowsArr as $row) { $lineDetails = $row; $item_array = explode (",", $row); if (in_array($max,$item_array)) { echo("Post Code - " . $item_array[0]. "<br>"); echo("Price - " . $item_array[1]. ",000 <br>"); echo("Picture - " . $item_array[2]. "<br>"); echo("Number of Visits - " . $item_array[3]. "<br>"); echo("<br>"); } } fclose($fileOpen); } ?> What i need is for the user to input anything they wish for example: 4, which would search the array and find that the first house has had 4 visits or HA44CD, to find the last house on the list etc ... however unfortunatley its not working for, if anyone can help me i would grateful Thank You Consider this scenario: I'm using an ajax to make the form use only one page I got a multistep form with step3 being the result of step2, within step3 there is an "add more steps" button which duplicates step2 and step3, this can be done countless times. to complement this I added array to my input boxes something like this: Code: [Select] <input type="text" name="name[]" id="name"/> unfortunately, I'm not sure how to approach this in the php. In the step2 going to step3, I would call the brand id and use it in the database to get the results for step3, but now it's array I added the following lines $brand = $this->input->post('brand[]'); $this->load->model('MBest'); $q = $this->MBest->getbestmatching($brand[0]); But the $brand[0] doesn't works and triggers an error. And come to think of it, if I call a $brand[0] index, then everytime a person add a new step, it will always use the id of the first result. Are there any ideas on how to fix this problem? Thanks Why is it grouping the checked boxes instead of keeping them in order like area is? if(isset($_POST['submit'])){ for($i=0; $i<10; $i++){ echo "<br />Ignore = [".$_POST['ignore'][$i]."]"; if($_POST['ignore'][$i]!="true") echo ", Area = ".$_POST['area'][$i]; } } else { echo "<form method='post'><table>"; for($i=0; $i<10; $i++){ echo " <tr> <td><input type='checkbox' name='ignore[]' value='true' /></td> <td><input type='text' name='area[]' /></td> </tr>\n"; } echo " </table> <input type='submit' name='submit' value='Submit' /> </form>"; } Input: Quote Checked - ignored Unchecked - a Checked - ignored2 Unchecked - b Checked - ignored3 Unchecked - c Unchecked - d Checked - ignored4 Unchecked - e Checked - ignored5 Output: Quote Ignore = [true] Ignore = [true] Ignore = [true] Ignore = [true] Ignore = [true] Ignore = [], Area = c Ignore = [], Area = d Ignore = [], Area = ignored4 Ignore = [], Area = e Ignore = [], Area = ignored5 I have this form:
<form method="get"> I have a text file with the following: HA11QS, 200, house1.jpg, 4 HA22BR, 280, house2.jpg, 10 HA33AB, 390, house3.jpg, 3 HA44CD, 320, house4.jpg, 8 I have a form: Code: [Select] <?php if (isset($_POST['price'])) { $filename = "houses.txt"; $fileOpen = fopen($filename, "r"); $max = $_POST['price']; $rowsArr = file ($filename); foreach ($rowsArr as $row) { $lineDetails = $row; $item_array = explode (",", $row); if (((int) $item_array[1]) <= $max) { ?> <form action='visit2.php' method='post'> <?php echo("Post Code - " . $item_array[0]. "<br>"); echo("Price - " . $item_array[1]. ",000 <br>"); echo("Picture - " . $item_array[2]. "<br>"); echo("Number of Visits - " . $item_array[3]. "<br>"); ?> <input type='checkbox' name='mybox'> <input type='submit' value='Visit Property'> </form> <?php } } fclose($fileOpen); } ?> and i also have "visit.php" Code: [Select] <?php if (isset($_POST['mybox'])) { $filename = "houses.txt"; $fileOpen = fopen($filename, "r+"); $filename2 = "houses2.txt"; $fileWrite = fopen($filename2, "w"); $visit = $_POST['mybox']; $rowsArr = file ($filename); foreach ($rowsArr as $row) { $lineDetails = $row; $item_array = explode (",", $row); $fileText = $item_array[3]+1; if ($visit == true) { echo("Post Code - " . $item_array[0]. "<br>"); echo("Price - " . $item_array[1]. ",000 <br>"); echo("Picture - " . $item_array[2]. "<br>"); echo("Number of Visits - " . $item_array[3] . "<br>"); echo("<br>"); fwrite($fileWrite, $fileText); } } fclose($fileOpen); fclose($fileWrite); } ?> What i need is , when the user in the form, clicks on the checked box, it sends the information to 'visits.php' and it writes to the text file, increasing the selected value by one Please can anyone help, im really struggling with this Thank You Hi, I'm trying to pass values from an array into a form. As a newbie, I've came up with the code underneath, but I want to pinpoint all the first values toward 1 selection list in the form. Any suggestions how to accomplish this? Thanks in advance. Ruud <html> <head> <title>Test formulier</title> </head> <body> <h2>Test formulier</h2> <form action="test.php" method="post"> <p> <?php $prijzen = array( array("01", "125","150", "A" => true,"B" => true), array("02", "125","150", "A" => true,"B" => true), array("03", "125","150", "A" => true,"B" => false), array("04", "125","150", "A" => true,"B" => true) ); ?> </P> <select name="prijzen[]" id="prijzen" multiple="multiple" size="7" class="none"> <?php while(list($key, $val) = each($prijzen)){ while(list($key2, $val2) = each($val)){ echo '<option value="'.$key2.'">'.$val2.'</option>'.PHP_EOL; } } ?> </select> </body> </html> |