PHP - Receiving X-www-form-urlencoded Post
I have some data I'm posting from Swift to my php file via x-www-form-urlencoded. How can I decode this POST data? Similar Tutorialsi have a shopping cart set up with mysql with a $_COOKIE['cart_id'] used to call all rows with cart_id... i have a while loop print out all the items in the cart $sql2 = mysql_query("SELECT * FROM cart WHERE cart_id = '$cart_id'") or die(mysql_error()); while($row = mysql_fetch_array($sql2)){ then i have it echo out the name...desc... quantity of each item... but the quantity is set up to be able to change and i have a form set up and i'd like to have each item be able to be changed at once if they wanted....but being multiple rows... there could be multiple $_POST['quantity']... echo "<td><input type='text' name='quantity' value='".$quantity."'/></td>"; there is a unique id for each row in the table that i'd like to set up with an array to post... i'd like to set up an array $array[$uniq_id] => $quantity; and somehow POST this array name='$array[]' and then on the action end... be able to call it by having foreach($quantity as $uniq_id => $qty){ mysql_query("UPDATE cart SET quantity='$qty' WHERE id='$uniq_id' "); } i'm not sure if i'm approaching this the right way... the array part is leaving me stuck...any help is appreciated..thank you! I'm trying to set up paypal payment processing on my website. I have godaddy shared hosting (<--mistake) and I'm trying my hardest to not switch hosts. The payments process fine, it is the listener that I'm having problems with. Paypal POSTs data to a script for which you set the url to a "listener" script in your settings. When a payment is made.... they POST the data to the listener script... you encode the data...append it all together plus another variable and send it back to be verified that it matches... Well I'm not too worried about the script working and all that... the problem is I'm not even RECEIVING the post. I have a simple foreach loop gather and append the data into a string. I have it set up right now to insert into MYSQL just so I can SEE if it's working....You can check your IPN history and I can see that payments are made but paypal is sending it over and over it's in a "retrying" state with a 408 error. My server is not sending a 200ok response. After 4 days of bashing my head against the wall I figured out that there's a problem with godaddy shared hosting.. If I use a virtual private server with the SAME script from godaddy it works just fine. But on the shared hosting it blocks it for some reason...After calling paypal and godaddy countless times with them pointing their finger at each other... one godaddy support rep tells me that I should set my script up with a proxy and he gave me info which I will show you in the script... This is what I need help with right. How can I receive POST data through a proxy in my script.... I want to add that this doesn't make sense to me because in my script I also have the word "yes" insert into MYSQL even if the script is hit at all... All this time my script is NEVER even touched by paypal... So.. if I add this proxy stuff... how will let my script even be accessed? I'm not sure how servers work together too well to process things. It just didn't seem like the proxy thing would even help when my script can't even be accessed it seems. Any help is appreciated. Here's the simple code I'm working with: $con = mysql_connect("","","") or die(mysql_error()); $db = mysql_select_db("swellshirt",$con); $ip = "64.202.165.130"; // proxy IP <-- IP... $port = 3128; // proxy port $url_proxy = 'http://proxy.shr.secureserver.net'; // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } mysql_query("INSERT INTO orders (description, street) VALUES ('$req', 'yes') ") or die(mysql_error()); Good day i am not receiving emails when hitting submit; not sure if my code is correct. jtconfirmation.co.za <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Names Confirmation RSVP</title> <link rel="stylesheet" href="church.css"> </head> <body> <form action="/mail_form.php" method="POST" id="church-form"> <div class="top"> <nav> <a href="index.html" class="mybutton">Home</a> </nav> </div> <div class="form"> <div class="info"> <h1>RSVP</h1> <h2>for the Confirmation Service of</h2> <h1>Name</h1> <p class="line">________________________________________</p> <h2>The Details</h2> <p>Sunday, 28 February 2021</p> <p>10:00 AM</p> <p>Please RSVP by 15 February 2021</p> <h2>Confirmation Service</h2> <p><a href="#" target="_blank"> Calvyn Protestant Church Diep River</a></p> <p>10 Keswick St, Elfindale</p> <p class="line">________________________________________</p> <input type="text" value="name" placeholder="Name"> <input type="email" value="email" placeholder="Email"> </div> <?php echo((!empty($errorMessage)) ? $errorMessage : '') ?> <button type="submit" class="accept" value="Send">Accept</button> <button type="submit" class="regret" value="Send">Regret</button> </div> </form> <script src="//cdnjs.cloudflare.com/ajax/libs/validate.js/0.13.1/validate.min.js"></script> <script> const constraints = { name: { presence: {allowEmpty: false} }, email: { presence: {allowEmpty: false}, email: true } }; const form = document.getElementById('church-form'); form.addEventListener('submit', function (event) { const formValues = { name: form.elements.name.value, email: form.elements.email.value }; const errors = validate(formValues, constraints); if (errors) { event.preventDefault(); const errorMessage = Object .values(errors) .map(function (fieldValues) { return fieldValues.join(', ') }) .join("\n"); alert(errorMessage); } }, false); </script> </body> </html> s <?php use PHPMailer\PHPMailer\PHPMailer; require __DIR__ . '/vendor/autoload.php'; $errors = []; $errorMessage = ''; if (!empty($_POST)) { $name = $_POST['name']; $email = $_POST['email']; if (empty($name)) { $errors[] = 'Name is empty'; } if (empty($email)) { $errors[] = 'Email is empty'; } else if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors[] = 'Email is invalid'; } if (!empty($errors)) { $allErrors = join('<br/>', $errors); $errorMessage = "<p style='color: red;'>{$allErrors}</p>"; } else { $mail = new PHPMailer(); // specify SMTP credentials $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = 'name@example.com'; $mail->Password = 'P@ssword123'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->setFrom($email, 'Mailtrap Website'); $mail->addAddress('piotr@mailtrap.io ', 'Me'); $mail->Subject = 'RSVP Church'; // Enable HTML if needed $mail->isHTML(true); $bodyParagraphs = ["Name: {$name}", "Email: {$email}", "Message:", nl2br($message)]; $body = join('<br />', $bodyParagraphs); $mail->Body = $body; echo $body; if($mail->send()){ header('Location: thank-you.html'); // redirect to 'thank you' page } else { $errorMessage = 'Oops, something went wrong. Mailer Error: ' . $mail->ErrorInfo; } } } ?>
Hi there I am trying to send an array of items to delete from a form, receive them back to the page then enter them into another form and then send them back to the page. Basically its a delete then confirm delete thing. So I can send the array from the first form though I am not sure how to place them into the second (confirm delete) form. What I've got so far considering the array does get sent in the first place is First I receive the array: if (isset($_POST['delete'])) { if (isset($_POST['todelete'])){ $todelete[] = ($_POST['todelete']);////here is my problem I think echo <<<_END <div>Are you sure you wish to make these changes</div> <div><form action="" method="post"> <input type='hidden' name='todelete'value="$todelete"/> <input type='hidden' name='confirm'value="confirm"/> <input id='inputform' type='submit' size='50' value='Yes' /> </form> <form action="" method="post"> <input type='hidden' name='rollback'value='rollback' /> <input id='inputform' type='submit' size='50' value='No' /> </form></div> _END; } } Then I try and receive the array back with if (isset($_POST['confirm'])){ foreach ($_POST['todelete'] as $delete_id) { $query ="DELETE FROM gallery WHERE id = $delete_id"; $result=mysql_query($query) or die("Invalid Query : ".mysql_error()); echo "Removing Data"; } } What I receive is a warning: 'Warning: Invalid argument supplied for foreach() in C:\wamp\www\css\enterphotos.php on line 91" I am sure that there is a simple solution! Can anyone help me here? Hello fellow developers, Let me start by saying I'm still a PHP noob so please don't go too hard on me if I my code reflects this noobishness... So I'm trying to build a (very) simple RSS reader using jQuery and PHP. When the user clicks on an option from a dropdown, an AJAX call is made and passes the url selected from the list to a PHP script. The PHP script then loads the appropriate xml file from an 'xmlcache' folder. Everything is working just fine for files named as such: somefilename_1231231231.xml The problem is that I need it to be able to load files which have been urlencoded such as: http%3A%2F%2Ffeeds.feedburner.com%2Fajaxian_1235523548 In case you're wondering, the numbers at the end are a timestamp which will determine if the reader will load a cached copy of the desired xml file (if it's less than an hour old) or if it needs to get a fresh version (this part of the code is not written yet). Here is a look at my script thus far: <?php $url = "./xmlcache/" . urlencode($_REQUEST['url']); //access url from AJAX call echo $url; //outputs -> "./xmlcache/http%3A%2F%2Ffeeds.feedburner.com%2Fajaxian_1235523548.xml", which is the same as the file's name $curTime = time(); $urlParts = explode('_', $url); $urlTime = intval($urlParts[1]); $diff = $curTime - $urlTime; $urlAge = 60 * 60; //60sec * 60min = 3600sec or 1 hour if(file_exists($url)){ if($diff > $urlAge){ //the > will be switched to < to make logical sense once testing is done. $xml = simplexml_load_file($url); //ROOT TAG foreach($xml as $key0 => $value){ echo "$key0: $value"; foreach($value->attributes() as $attributeskey0 => $attributesvalue1){ echo "$attributeskey0: $attributesvalue1"; } echo "<br />"; //1 LEVEL BELOW ROOT TAG foreach($value as $key => $value2){ echo "$key: $value2"; foreach($value2->attributes() as $attributeskey => $attributesvalue2){ echo "$attributeskey = $attributesvalue2"; } echo '<br />'; //2 LEVELS BELOW ROOT TAG foreach($value2 as $key2 => $value3){ echo "$key2: $value3"; foreach($value3->attributes() as $attributeskey2 => $attributesvalue3){ echo "$attributeskey2 = $attributesvalue3"; } echo '<br />'; //3 LEVELS BELOW ROOT TAG foreach($value3 as $key3 => $value4){ echo "$key3: $value4"; foreach($value4->attributes() as $attributeskey3 => $attributesvalue4){ echo "$attributeskey3 = $attributesvalue4"; } echo '<br />'; //4 LEVELS BELOW ROOT TAG foreach($value4 as $key4 => $value5){ echo "$key4: $value5"; foreach($value5->attributes() as $attributeskey4 => $attributesvalue5){ echo "$attributeskey4 = $attributesvalue5"; } echo '<br />'; //5 LEVELS BELOW ROOT TAG foreach($value5 as $key5 => $value6){ echo "$key5: $value6"; foreach($value6->attributes() as $attributeskey5 => $attributesvalue6){ echo "$attributeskey5 = $attributesvalue6"; } echo '<br />'; } } } } echo '<br />'; } echo '<br />'; } }else{ //need to create the XML file from scratch, do a curl function, or read from a text file echo "need a new version"; //@unlink("$url); } }else{ echo "That file does not exist.<br/>"; } ?> The error message I'm getting is this: Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "./xmlcache/http%3A%2F%2Ffeeds.feedburner.com%2Fajaxian_1235523548.xml" in C:\wamp\www\reader\loadfeed.php on line 13 Warning: Invalid argument supplied for foreach() in C:\wamp\www\reader\loadfeed.php on line 16 The second error is obviously thrown because the file doesn't get loaded. I appreciate any help you gurus have to offer, and if you have any suggestions for the best way to load a fresh version that will be handled by the first else statement, I'm all ears. Thanks guys! Hey Guys. I am working with a form that shows the grand total on the checkout page. The value of the grand total is inside a hidden field. When click on submit, the _POST array doesn't get back the last value of the grand total. I need to hit the button twice to get the last value. The weird thing is when I echo the value of the grand total it display the latest value, but not with the POST array
For example. If the grand total is $10.00 and I click on submit. It will show the POST['grand_total'] as empty. If I click on submit again it will show the grand total of $10.00.
Below is my code that I am working with. Any help would be really appreciated.
if(isset($_POST['submit'])) { /* Doesn't show if i put it after if($_POST['submit'] */ if(isset($_POST['grand_total'])) { echo $_POST['grand_total']; } } //A bunch of other html/php code. Another class calculates the subtotal assigns it the variable $subtotal $cart_totals = new cartTotals($subtotal, $discounted_amount,$post_values->tip); // Cart class is shown below /* Doesn't show if i put it before if($_POST['submit'] */ if(isset($_POST['grand_total'])) { echo $_POST['grand_total']; } echo "<input name='grand_total' type='hidden' value='$cart_totals->grand_total' />"; // Shows the grand total after second from submission echo "$cart_totals->grand_total"; // Shows grand total after the first submissionCart Totals Class class cartTotals { public $subtotal; public $sales_tax; public $tip; public $grand_total; public $discount_amount; public $href_page; public $invalidCouponMessage; const TEST_ENVIORMENT = FALSE; /** * [ Function gets constructed in the order summary where the [$discount_amount= ""] arg does need to be passed. * But does get passed in when called on the checkout.php page. Therefore we set the default value to an empty string.] * @param [float] $subtotal [subtotal get passed in from the parent class coreCartFunction] * @param string $discount_amount [The class checkCouponCode calculates this discount amount based on the * subtotal and the discount amount. It gets instantiated on the clients side and passed is this construction function. * This is all done on the checkout page.] */ /*The way the construct function works is by invoking all the methods the passed arguments When the methods get invoked the do all the work and set the properties its values. The properties then get echoed out on the client side. */ function __construct($subtotal="", $discount_amount= "", $tip=""){ $this->subTotal($subtotal, $discount_amount);//SubTotal method takes the discount amount and subtracts it from the subtotal. $this->salesTax($subtotal, $discount_amount); $this->tip = $tip; $this->grandTotal(); } private function subTotal($subtotal,$discount_amount) { $rounded_subtotal = round($subtotal-$discount_amount,2); $money_format_subtotal = money_format('%i',$rounded_subtotal); $this->subtotal = $money_format_subtotal; } private function salesTax($subtotal, $discount_amount =""){ $sales_tax = (STORE_SALES_TAX)?(float)STORE_SALES_TAX:8.875; $sales_tax =(($this->subtotal)*$sales_tax)/100; $sales_tax = round($sales_tax,2); $this->sales_tax = $sales_tax; } public function Tip() { //global $post_values; //$last_tip_selected = $post_values->tip > 0 ? $post_values->tip : "" ; $tip_output = "<select id='tip' name='tip'>"; for($tip=0.00; $tip<=11.75; $tip+=0.25){ if( $tip == "2") {$selected = " selected";} else {$selected ="";} $formatted_tip = money_format('%i',$tip); $tip_output .= "<option {$selected} id='selected_tip' value='$formatted_tip'>"."$".$formatted_tip ."</option>".PHP_EOL; } $tip_output .= "</select>"; return $tip_output; } private function grandTotal(){ $grand_total = round($this->sales_tax+$this->subtotal+$this->tip,2); $grand_total_formatted = money_format('%i',$grand_total); $this->grand_total = $grand_total_formatted; } This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=347360.0 Hi, I am having a problem with my form. It posts fine on Firefox 3.6 on my MAC, but not on Safari 5 on my MAC. It also does not work Internet Explorer 9, Firefox 4 or Google Chrome on a windows box. Basically it posts back to itself, no email is sent and it does not hit my sql database. Here is the pertinent code to my index.html file... Code: [Select] <script type="text/javascript"> function showMonth(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","reserv.php?q="+str,true); xmlhttp.send(); } </script> <form method="post" action="resersend.php"> <p><font face="arial" size="2" color="#336600">Reservation month:</font> <select name="months" onchange="showMonth(this.value)"> <option value="" selected="selected">Choose One</option> <option value="May 2011">May 2011</option> <option value="June 2011">June 2011</option> <option value="July 2011">July 2011</option> <option value="August 2011">August 2011</option> <option value="September 2011">September 2011</option> <option value="October 2011">October 2011</option> <option value="November 2011">November 2011</option> <option value="December 2011">December 2011</option> <option value="January 2012">January 2012</option> <option value="February 2012">February 2012</option> <option value="March 2012">March 2012</option> <option value="April 2012">April 2012</option> </select> </form></p> Here is the reserv.php file (code) that works with the html file.... Code: [Select] <?php $q=$_GET["q"]; $con = mysql_connect('my_host', 'my_user', 'my_pwd'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $sql="SELECT * FROM daterange WHERE DEND > DATE(NOW()) AND STATUS='A' AND MONTH = '".$q."' ORDER BY RID, DATE, SITE"; $result = mysql_query($sql); // Determine the number of reservation dates $number = mysql_numrows($result); // Create drop-down menu of reservation dates print "<font size=\"3\" face=\"Arial\"><b>Select Your Reservation:</b><br> <form action=\"resersend.php\" method=\"post\"> <select name=\"RID\"> <option value=\"\">Choose One</option>"; for ($i=0; $i<$number; $i++) { $RID = mysql_result($result,$i,"RID"); $DATE = mysql_result($result,$i,"DATE"); $SITE = mysql_result($result,$i, "SITE"); $PRICE = mysql_result($result,$i, "PRICE"); print "<option value=\"$RID\">$DATE, $SITE, $PRICE</option>"; } print "</select><p align=left><label><font size=\"3\" face=\"Arial\">First Name: <input type=\"text\" name=\"FNAME\" size=\"50\" maxlength=\"50\" tabindex=\"1\"<br>"; print "<p align=left><label>Last Name: <input type=\"text\" name=\"LNAME\" size=\"50\" maxlength=\"50\" tabindex=\"2\"<br>"; print "<p align=left><label>Address Line 1: <input type=\"text\" name=\"ADDR1\" size=\"50\" maxlength=\"50\" tabindex=\"3\"<br>"; print "<p align=left><label>Address Line 2: <input type=\"text\" name=\"ADDR2\" size=\"50\" maxlength=\"50\" tabindex=\"4\"<br>"; print "<p align=left><label>City: <input type=\"text\" name=\"CITY\" size=\"50\" maxlength=\"50\" tabindex=\"5\"<br>"; print "<p align=left><label>State (abbrev.): <input type=\"text\" name=\"STATE\" size=\"2\" maxlength=\"2\" tabindex=\"6\"<br>"; print "<p align=left><label>Zip Code: <input type=\"text\" name=\"ZIP\" size=\"5\" maxlength=\"5\" tabindex=\"7\"<br>"; print "<p align=left><label>Contact Phone Number: (<input type=\"text\" name=\"PHONE1\" size=\"3\" maxlength=\"3\" tabindex=\"8\""; print "<label>)<input type=\"text\" name=\"PHONE2\" size=\"3\" maxlength=\"3\" tabindex=\"9\""; print "<label>-<input type=\"text\" name=\"PHONE3\" size=\"4\" maxlength=\"4\" tabindex=\"10\"<br>"; print "<p align=left><label>Email: <input type=\"text\" name=\"EMAIL\" size=\"50\" maxlength=\"50\" tabindex=\"11\"<br>"; print "<p align=left><input type=\"submit\" value=\"Book Now!\" name=\"submit\">"; print "<input type=\"reset\" value=\"reset\" name=\"reset\"></form>"; // Close the database connection mysql_close($con); ?> Anyone have any ideas? I suspect it may have to do with the javascript in the index.html file, but I can't nail it down. Thanks. Ok so I've got trouble with a form I'm creating, I've got this: <form id="login" name="login" action="URL" method="post"> and then Input fields like: <input tabindex="3" type="text" class="login-field" name="acc.username" id="login-username" value="" maxlength="48"/> Now, if I go and submit that, and on the "URL" page I've had it echo $_POST['acc.username'] but it doesn't echo anything. I think it may be a problem with the form itself.. although I can't see one. The code I got for URL: <?PHP include('global.php'); if(isset($_POST['acc.username'])) { echo "lol"; } else { echo mysql_error(); } ?> In my invoice system im trying to carry information from 1 page to another, witch i have been successful with, now I am trying to alter table rows on my data tables I need to send the same account number and invoice number, how can i achieve this without putting the account number and invoice number inside a form element? why doesn't this work? Code: [Select] <form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="text" id="name" name="name" size="20" /></p> <input type="submit" name="submit" value="Submit" alt="Submit" /> </form> <? if($name != "") { $xml = simplexml_load_file("invoice.xml"); $sxe = new SimpleXMLElement($xml->asXML()); $itemsNode = $sxe->data[0]; $main = $itemsNode->addChild(inv); $sub = $main->addChild("name", $name); $sxe->asXML("invoice.xml"); } ?> The existing xml file looks like this: Code: [Select] <?xml version="1.0" encoding="utf-8"?> <root> <data> <inv> <name>Sally Prince</name> </inv> </data> </root> And, my intention is is I fill out the form with "Bill Gates" the xml will become: Code: [Select] <?xml version="1.0" encoding="utf-8"?> <root> <data> <inv> <name>Sally Prince</name> </inv> <inv> <name>Bill Gates</name> </inv> </data> </root> Also if I just set Code: [Select] $name = "Bill Gates" it works.. but the form will not pass the data to the xml.. what am I missing? Thanks! How can i make a send POST FORM from this api: http://pub.tapulous.com/tapplications/coresocial/v1/chat/api/index.php?method=message_send&session={"device_id":+"03decef7aad6fb64fb5c5ed3f1d35a3d16413e490a2874",+"room":+"Songs%253AExtreme"}&message= message here Thanks people Hi all, not sure if this belongs in the Javascript section or PHP... I have a 3 pages, Index.php, a Javascript file and my display.php page. My Index page has a list of inputs which populate the variables in my javascript file when exectued, the javascript file then uses these variables to perform simple mathematical calculations and then displays the data using the innerHTML function back on my index page. From the index page I need to then post all my values, including these in the innerHTML div's as a POST array to my display.php only im unsure where to start. Hopefully thaat makes sense, would anybody have any idea on how to do this? Thanks My specific situation is SEOMoz, but this is a general question. I have a pretty extensive series of tools that rely on the SEOMoz api. They recently implemented 1 request per 10 seconds throttle limit. Is there a way I can run one request, stop for 10 seconds, and run the next, and so on? Anyway to get around something like this, without breaking their TOS? Hi I am really getting with validating a drop down box in my form for posting I have set all the <options> in html form as followed: <form method="post" action="thankyou.php"> <?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 ?>" /> <select name="visitortitle"> <option>Please Select</option> <option value="Mr">Mr</option> <option value="Mrs">Mrs</option> <option value="Miss">Miss</option> <option value="Ms">Ms</option> <option value="Dr">Dr</option> </select> </form> now I'm trying to find a way to validate it in the .php sending side and using this: <?php $visitortitle = $_POST['visitortitle']; if (!isset($visitortitle)) { echo $visitortitle; } mail("email@domain.com", $subject, $message, $from); ?> I have tried so many different ways with - if (!isset - but cant get the send mail to recognise the drop down menu selection!!!! Any help would really be appreciated as I'm not that up on php coding. Thanks in advance. Gary Hi all, Hoping someone can help with what i would guess is a very simple problem. I have the following code which is suppose to display a form. the form posts to itself and uses isset and if the form has been posted it doesnt display the form. if (isset($_POST['submit'])) { echo "question submitted successfully"; } else { echo '<form method="post" name="qanda" id="qanda" action="http://' . $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] . '">'; echo '<p><label for="name">Name</label> <input type="text" id="name" /></p>'; echo '<p><label for="e-mail">E-mail</label> <input type="text" id="e-mail" /></p>'; echo '<p><label for="Question">Question</label> <textarea rows="6" id="question"></textarea></p>'; echo '<p class="submit"><input type="submit" value="Submit" /></p></form>'; } this currently doesnt work. Extra things you might need to know is that this script/form is an included file in a dynamic site which also uses the rewrite module which is why I am using http://' . $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] just incase that makes a difference. Hello! Ok so I already have a "post" action URL, here it is below. <form method="post" action="http://survey.leisuretrends.com/RemoteSurvey.asp?survey=321&survey_version=1330"> The idea is to put a simple e-mail form on my personal website: And have the post action to go to the URL above (its a marketing company for email submissions / newsletters) Here is what I have so far, but I know something is not right: Quote <form> <input type="text" /> <input type="submit" /> <form method="post" /> <form action="http://survey.leisuretrends.com/RemoteSurvey.asp?survey=321&survey_version=1330"/> </form> Any help would be greatly appreciated. Thank you for your patience with me Please help me. I tried to make a form from my database, and calculate the product of values which was selected. Code: [Select] <?php $dbconn = pg_connect('host=localhost port=5432 dbname=test user=test password=test'); if(!$dbconn) { exit('DB Connect Failed!'); } $result = pg_query( $dbconn, " SELECT * FROM record " ); if(!$result){ exit('SELECT Failed!!!'); } $rows = pg_fetch_all($result); ?> <html><body> <form name="cal" method="post" action="cal2.php"> <?php if(!$rows): ?> <div>No data was found.</div> <?php else: ?> <table> <tr> <th class="ass">object name</th> <th class="ass" colspan="3">price</th> </tr> <?php foreach($rows as $r): ?> <tr> <td><?php echo $r['object_name']; ?></td> </td> <td> <input type="radio" name="<?php echo $r['object_name'] ?>" value="<?php echo $r['price_1'] ?>"> <?php echo $r['object_1'] ?></td> <td> <input type="radio" name="<?php echo $r['object_name'] ?>" value="<?php echo $r['price_2'] ?>"> <?php echo $r['object_2'] ?></td> <td> <input type="radio" name="<?php echo $r['object_name'] ?>" value="<?php echo $r['price_3'] ?>"> <?php echo $r['object_3'] ?></td> </tr> <?php endforeach; ?> </table> <?php endif; ?> <input type="submit" name="submit" value="SUBMIT"> <input type="reset" value="CLEAR"> <br><br> </form> I can get values from selected object, but I don't know how to calculate their total product. Code: [Select] <?php foreach ( $_POST as $key => $val ) { $selval = "$val, "; echo $selval; } //echo values from selected objects. ex. 12, 15, 13.... //then, product each values. ex. 12*15*13... $p = 1; foreach ( $_POST as $key => $val ) { $p *= $val; echo $p; } //it didn't work foreach ( $_POST as $key => $val ) { $a = array($val); echo array_product($a); } //it didn't work ?> I have created a Post php form, It send two emails, One email to the user after they submit the form and other to me. Now the users will fill up the form in arabic and a confirmation email will be sent to them in arabic also...I tested my form, I get the confirmation email in arabic, its fine, but the data tht the user inputs in arabic on the form comes to my email with strange characters.....i want to receive the data entered by user in arabic. Below is the HTML and Php Here is my HTML Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="ar" xml:lang="ar" xmlns="http://www.w3.org/1999/xhtml"> <head> <link href="../../css/cssfinal.css" type="text/css" rel="stylesheet"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Language" content="ar"> <title>Untitled Document</title> <style type="text/css"> <!-- body { background-color: #FFFFFF; } .style8 {color: #FF0000} --> </style> <script src="../../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <script src="../../SpryAssets/SpryValidationSelect.js" type="text/javascript"></script> <link href="../../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> <link href="../../SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" /> </head> <body> <table align="center" width="547" border="0" cellpadding="0" cellspacing="0"> <tr> <td> </td> </tr> <tr> <td> </td> </tr> </table> <form method="post" name="enquiry" action="sendmailsqlar.php"> <table width="547" align="center" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="101" background="../../images/formhead.png"><div align="center" class="status" style="margin-bottom:20px; margin-top:20px">نموذج الاستفسار عن الدورة الأكاديمية</div></td> </tr> </table> <table width="547" border="0" align="center" cellspacing="0" cellpadding="0"> <tr> <td width="275"><div align="right"><input name="Name" type="text" id="visitor" value="" size="36" class="field" /></div></td> <td width="272" align="right"><div style="margin-left:25px; margin-bottom:10px; margin-top:10px; font-size:18px;"> <div style="margin-right:25px;">الاسم</div> <span id="sprytextfield1"><span class="textfieldRequiredMsg">مطلوب</span></span></div></td> </tr> <tr> <td><div align="right"><input name="Email" type="text" id="visitormail" size="36" class="field" /></div></td> <td align="right"><div style="margin-left:25px; margin-bottom:10px; margin-top:10px; font-size:18px;"> <div style="margin-right:25px;">البريد الإلكتروني</div> <span id="sprytextfield2"><span class="textfieldRequiredMsg">مطلوب</span><span class="textfieldInvalidFormatMsg">غير صحيح </span></span></div></td> </tr> <tr> <td><div align="right"><input name="Nationality" type="text" id="nationality" size="36" class="field" /></div></td> <td align="right"><div style="margin-left:25px; margin-bottom:10px; margin-top:10px; font-size:18px;"> <div style="margin-right:25px;">الجنسية</div> <span id="sprytextfield2"><span class="textfieldRequiredMsg">مطلوب</span></span></div></td> </tr> <tr> <td align=""><div align="right"> <select name="Level" id="stulevel" size="1" class="select"> <option value=""><span class="drop.Text">(إختر)</span></option> <option value=" Foundation/Diploma ">دبلوم</option> <option value=" Bachelor Degree ">البكالوريوس</option> <option value=" Master Degree ">ماجستير</option> <option value=" PhD./Others ">دكتوراه</option> </select> </span></div></td> <td align="right"><div style="margin-left:25px; margin-bottom:10px; margin-top:10px; font-size:18px;"> <div style="margin-right:25px;">المرحلة الدراسية المطلوبه</div> <span id="spryselect1"><span class="selectRequiredMsg">مطلوب</span></span></div></td> </tr> <tr> <td><div align="right"><input name="Field" type="text" id="stfield" size="36" class="field" /></div> </td> <td align="right"><div style="margin-left:25px; margin-bottom:10px; margin-top:10px; font-size:18px;"> <div style="margin-right:25px;">مجال الدراسة \ التخصص</div> <span id="sprytextfield3"><span class="textfieldRequiredMsg">مطلوب</span></span></div></td> </tr> <tr> <td colspan="2"><table width="547" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="275"><label> <div align="right"><textarea name="Message" style="background-color:#ccc2b2" class="field" id="message" cols="27" rows="6"></textarea></div> </label></td> <td width="272" align="right"><div style="margin-left:25px; margin-bottom:10px; margin-top:10px; font-size:18px;"> <div style="margin-right:25px;">ملاحظات</div> </div></td> </tr> </table></td> </tr> <tr> <td colspan="2" height="101" background="../../images/formfoot.png"><div align="center" style="margin-top:15px"> <input type="submit" class="btn1" value="إرسال" /> </div></td> </tr> </table> </form> <script type="text/javascript"> <!-- var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email"); var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3"); var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1"); var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4"); //--> </script> </body> </html> Here is the PHP Code: [Select] <html dir="rtl"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="ar"> </head> <?php $to = "xx@xxx.com"; $visitor = $_REQUEST['Name'] ; $visitormail = $_REQUEST['Email'] ; $nationality = $_REQUEST['Nationality'] ; $stulevel = $_REQUEST['Level'] ; $stfield = $_REQUEST['Field'] ; $message = $_REQUEST['Message'] ; $header = "From: $visitormail\n" . "Reply-To: $visitormail\n"; $subject = "Arab Enquiry"; $message = "From: $visitor \n\n Email: $visitormail \n\n Nationality: $nationality \n\n Level: $stulevel \n\n Field: $stfield \n\n Message: $message"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to, $subject, $message, $header); //Sending auto respond Email to visitor $reply_header = "From: ttt@ttt.com\n" . "Reply-To: vvv@vvv.com\n"; $reply_subject = " - تم استلام طلبكم"; $reply_to = "$visitormail"; $reply_message = "$visitor \n\n شكرا لزيارتكم موقعنا . \n نود ابلاغكم بأنه تم استلام طلبكم وسوف يتم الرد عليكم قريبا.\n هذه الرسالة مرسلة من نظام الموقع.\n شكرا\n ."; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($reply_to, $reply_subject, $reply_message, $reply_header); header("Location: thankyouar.html"); ?> please help !!!! i would appreciate |