PHP - Very Simple Post Form In Php, Help Please!!!!!! Thanks
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 Similar TutorialsI have the simple code below which seems to have worked on forms from a contact page on a website. Unfortunately, it seems to only send the forms if all fields are entered. I have played with the code but cannot seem to get it to send any field that has been completed on submit. Can someone help please? <?php $emailAddress = "bigL@gmail.com"; $thankyouPage = ""; session_start(); if (!empty($_POST)) { foreach ($_POST as $key=>$value) { $_POST[$key] = stripslashes($_POST[$key]); $_POST[$key] = htmlspecialchars($_POST[$key],ENT_QUOTES); } } if (isset($_POST['send']) AND isset($_SESSION['msgCount'])) { if ($_SESSION['msgCount'] >= "3") $alert = "Only 3 messages can be s +ent per session."; if (empty($alert)) { $_SESSION['msgCount']++; putenv('TZ=EST5EDT'); // eastern time $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n" +; $message = "<table cellpadding='5' border='1'>"; foreach ($_POST as $key => $value) if (!preg_match("(^send)",$key)) { $value = wordwrap($value,65,"<br />"); $message .="<tr><td><b>$key</b></td><td>$value</td></tr>"; } $message .= "</table>"; $message .= "<br />Time of the message: ".date(" F d h:ia")."<br +/>"; $message .= "IP Address: ".$_SERVER['REMOTE_ADDR']."<br />"; $message .= "Hostname: ".gethostbyaddr($_SERVER['REMOTE_ADDR'])."< +br />"; $subject = $_SERVER['HTTP_HOST']." Message"; mail($emailAddress,$subject,$message,$headers); if (!empty($thankyouPage)) { header('location: '.$thankyouPage); die(); } unset($_POST); $alert = "Your enquiry has been sent, we will respond as soon as p +ossible."; } } if (!isset($_SESSION['msgCount'])) $_SESSION['msgCount'] = 0; ?> ok..ive done this a million times..i have a working example here and i copied it and amended it for this new project but for some reason i cant get a form to post data to another page. this is the error message i get Notice: Undefined index: username in C:\wamp\www\uni\fyp\site\mobile\login.php on line 16 Notice: Undefined index: password in C:\wamp\www\uni\fyp\site\mobile\login.php on line 17 here is my form code: <form method="post" action="login.php"> <table align="center" cellpadding="0" cellspacing="0"> <tr> <td style="vertical-align:top;">Username: </td><td><input type="text" name="username" value="" /></td> </tr> <tr> <td style="vertical-align:top;">Password: </td><td><input type="password" name="password" value="" /><br /><input type="submit" id="submit" value="Login" /></td> </tr> </table> </form> and here is the code within the login.php where the form should post to $username = $_POST['username']; $password = $_POST['password']; // Help protect against MySQL injection $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); // Selecting data from database where correct username and password are found $sql="SELECT * FROM customer WHERE username='$username' and password='$password'"; $result=mysql_query($sql) or die(mysql_error()); i cant see anything wrong..been looking for hours...please please help me 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; } I'm trying to make a newspaper page - I have a simple code but when i hit submit nothing happens, just page refreshes. Help would be great! Code: Code: [Select] <?php session_start(); include "includes/db_connect.php"; include "includes/functions.php"; logincheck(); $username=$_SESSION['username']; $query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1"); $fetch=mysql_fetch_object($query); $above = mysql_query("SELECT * FROM users WHERE username='$username'"); $info = mysql_fetch_object($above); $admin=$info->editor ; if($admin !=1){ echo"<center> This information is limited to Editors only!"; }else{ if ($_POST['Submit']){ $edition = $_POST['edition']; $news = $_POST['news']; $title = $_POST['title']; $by = $_POST['by']; $date = gmdate('Y-m-d h:i:s'); mysql_query("INSERT INTO `paper` ( `edition` , `news` , `title` , `by` , `date` ) VALUES ( '', '$edition', '$news', '$title', '$by', '$date' )"); echo "Article has been added"; } ?> <form name="form1" method="post" action=""> <table width="450x" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#000000" class="Main"> <tr class="Tableheading"> <td class="TableHeading">Add an Article</td></tr> <tr> <td class="TableArea" align="center">Edition: <input name="edition" type="text" id="edition" value="" size="30"> </td></tr> <tr> <td class="TableArea" align="center">Article: <input name="news" type="text" id="news" value="" cols="80" rows="5"> </td></tr> <tr> <td class="TableArea" align="center">Title: <input name="title" type="text" id="title" value="" size="30"> </td></tr> <tr> <td class="TableArea" align="center">Author: <input name="by" type="text" id="by" value="" size="30"> </td></tr> <tr><td class="TableArea" align="center">Add this article: <input name="submit" type="submit" class=button id="submit" value="Add Article"><br> </td></tr> </table> </form> <? } ?> Hey all. I am a php newbie. Just starting to get my feet wet. So my issue is this. I have a MySQL database table called "blog" Within that table are "ID, photo_id, post_head, post_body" I have connected to the database via php and have been successfully echoing the fields onto my page. But the problem is that I don't know how to create a loop. I need it to show the latest post (biggest ID #) first then display descending down. Here is my code. As you can see I'm echoing the same variables and logically its displaying the SAME post 2 times. Any help would be just great! <table width="925" border="0" cellspacing="0" cellpadding="0"> <tr> <? $data = mysql_query("SELECT * FROM blog ORDER BY id DESC") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { $id = $info['ID']; $photo_id = $info['photo_id']; $post_head = $info['post_head']; $post_body = $info['post_body']; } ?> <!-- POST 1 START --> <td width="180"> <img src="<? echo $photo_id ?>" /> </td> <td id="box_bg2" class="padding_state" width="275" valign="top"> <br /> <font id="post_head"> <? echo $post_head ?> </font> <br /> <font id="post_body"> <? echo $post_body ?> </font> </td> <td width="15"> </td> <!-- POST 2 START --> <td width="180"> <img src="<? echo $photo_id ?>" /> </td> <td id="box_bg2" class="padding_state" width="275" valign="top"> <br /> <font id="post_head"> <? echo $post_head ?> </font> <br /> <font id="post_body"> <? echo $post_body ?> </font> </td> </tr> </table> <td> <button onclick="alertdialog()"><span class="glyphicon glyphicon-trash"> </span></button></td> <script> function alertdialog(){ window.confirm("Are you sure you want to delete this post?"); } </script> This is my code. I need to have a callback to a PHP script when a user decides to delete a post. I think html POST is the most unobtrustive way to do this. What's the easiest / most robust way to send data to a script when the user clicks OK? Appreciated. Mark This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=347360.0 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 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! 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 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. 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? 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(); } ?> 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. 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 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 ?> Hello! 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 Hi all, I have a page with 4 textboxes which can be filled out. The thing is I want people to be able to only train 1 type at a time. Underneath I posted the Form page and the exec page does anyone have and idea?? Thnx Ryflex FORM: <?php //authentication & database configuration require_once('auth.php'); require_once('config.php'); //member_ID and city_ID and greyed out empty declaration $member_ID = $_SESSION['SESS_MEMBER_ID']; $city_ID = $_SESSION['SESS_CITY_ID']; $ro = ""; //Database connection $global_dbh = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Could not connect to database"); mysql_select_db(DB_DATABASE, $global_dbh) or die("Could not select database"); //get infantry units type = 1 $sql = "SELECT name, resource_1, resource_2, resource_3, timestamp FROM unittype WHERE type = 1"; $result = mysql_query($sql) or die("Could not find units"); //get the 4 unit types in the $n[] array while($data = mysql_fetch_assoc($result)) { $one[] = $data[resource_1]; $two[] = $data[resource_2]; $three[] = $data[resource_3]; $time[] = $data[timestamp]; } //query amount of infantry troops $sql = "SELECT * FROM infantry WHERE member_id = '$member_ID'"; $result = mysql_query($sql) or die("Could not find amount of troops"); //get amount of infantry troops while($data = mysql_fetch_assoc($result)) { $n[] = $data[name]; $training[] = $data[training]; $timestamp[] = $data[timestamp]; $amount[] = $data[amount]; } //check if a training is underway $sql = "SELECT * FROM infantry WHERE member_id = '$member_ID' AND training = 1"; $trcurr = mysql_fetch_array( mysql_query($sql)); if($trcurr['training'] == 1) { $ro = "READONLY STYLE='color:#999999;background:#DEDEDE'"; } ?> <html> <head> <title>Infantry Training</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body> <p>You can only train 1 type of infantry at a time.</p> <form id="create" name="create" method="POST" action="infantry_exec.php"> <table> <tr> <td><b><?php echo $n[0]; ?></b></td> <td><b><input name="<?php echo $n[0]; ?>" type="text" <?php echo $ro; ?> maxlength="10" id="<?php echo $n[0]; ?>" /></b></td> </tr> <tr> <td><b><?php echo $n[1]; ?></b></td> <td><b><input name="<?php echo $n[1]; ?>" type="text" <?php echo $ro; ?> maxlength="10" id="<?php echo $n[1]; ?>" /></b></td> </tr> <tr> <td><b><?php echo $n[2]; ?></b></td> <td><b><input name="<?php echo $n[2]; ?>" type="text" <?php echo $ro; ?> maxlength="10" id="<?php echo $n[2]; ?>" /></b></td> </tr> <tr> <td><b><?php echo $n[3]; ?></b></td> <td><b><input name="<?php echo $n[3]; ?>" type="text" <?php echo $ro; ?> maxlength="10" id="<?php echo $n[3]; ?>" /></b></td> </tr> <tr> <td colspan="2"><center><input type="submit" name="Submit" value="Train!!!" /></center></td> </tr> </table> </form> </body> </html> EXEC: <?php //authentication & database configuration require_once('auth.php'); require_once('config.php'); //member_ID and city_ID $member_ID = $_SESSION['SESS_MEMBER_ID']; $city_ID = $_SESSION['SESS_CITY_ID']; //Database connection $global_dbh = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Could not connect to database"); mysql_select_db(DB_DATABASE, $global_dbh) or die("Could not select database"); //query names of infantry troops $sql = "SELECT * FROM infantry WHERE member_id = '$member_ID'"; $result = mysql_query($sql) or die("Could not find amount of troops"); //get names of infantry troops while($data = mysql_fetch_assoc($result)) { $n[] = $data[name]; } //convert POST to normal variable $amount = array(0 => $_POST[$n[0]], 1 => $_POST[$n[1]], 2 => $_POST[$n[2]], 3 => $_POST[$n[3]]); ?> OK, have no idea what's going on... I've done this a million times... why wont this output!?? I must have a major brain meltdown and dont know it yet!!! Code: [Select] <?php // this echoes just fine: echo $_POST['testfield']; // but this wont echo: echo if (isset($_POST['testfield'])) { $_POST['testfield'] = $test; } echo $test; /// or even this DOESNT echo either!: $_POST['testfield'] = $test; echo $test; ?> |