PHP - Trouble Posting
TWO questions:
I haven't actually CONNECTED and POSTED. My form has two input fields that combine in a TOTAL field. I notice that the address bar is carrying TOTAL=input1+input2 when it TRIES to connect. Do I need to include the TOTAL field in the database if the info is NOT relavant data? the strg and chick TOTALS? Will the database accept PARTIAL data from a form that has 25 field with only 6 being populated for testing? Similar TutorialsWorking on a project for school and I am trying to code a form that feeds into a DB. I have been studying the syntax, reading and doing everything I can to get this to work. A little help, pointers, direction would be greatly appreciated. It may be my database structure so I included a image for anyone to see... and the files. Thanks in advance [attachment deleted by admin] This is more of a Paypal question, but I'm using php on the listener and hopefully someone has run into this problem. I'm having trouble finding the correct POST name to use to get the OPTION SELECT for the item on my listener page. I tried: $option = $_POST['os0']; But, I'm not getting anything using that. I've also tried os0_x, on0, and on0_x. This is what I'm posting to Paypal: <input type="hidden" name="on0" value="Term"> <select name="os0"> <option value="1 Year">1 Year</option> <option value="3 Years">3 Years</option> <option value="5 Years">5 Years</option> </select> Edited November 3, 2019 by jakebur01 Hi all, I have a situation where I need to remember what check boxes where checked over pagination, I have managed to do this via the use of this: http://jamesfunk.com/wordpress/?p=65 The problem is that as the code stood: Code: [Select] <input type="checkbox" name="compare" value="<?php echo $list['jobseeker_id'];?>" class="remember_cb"/> It was treating one ticked checkbox as them all because they all have the same name and are in the a while loop! I countered this by changing the code to: Code: [Select] <input type="checkbox" name="compare<?php echo $list['jobseeker_id']?>" value="<?php echo $list['jobseeker_id'];?>" class="remember_cb"/> Which effectively now makes the checkbox name unique... i.e. compare{id}. The problem with this is that I can now no longer process it. This is my processing code: $jobseekers = $_POST['compare']; $i = 0; for($i; $i<count($jobseekers); $i++){ $query = "SELECT * FROM jobseekers WHERE jobseeker_id = '$jobseekers[$i]'"; $result = mysql_query($query) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { // Spit out the required data } } As you can see I am trying to get the data from $_POST['compare'], which will obviously now be blank as I have had to make the name unique.... the trouble is I'm not sure how to actually process this. Can anyone help me out here? any help or advice would be greatly appreciated! many thanks, Greens85 i'm doing a form that posts values to XML, and i don't know how. can someone help me with a quick lesson in passing variables/XML data? i don't even know what question to ask, actually - the XML format i've been given is: Code: [Select] <?xml version="1.0" encoding="UTF-8"?> <lead> <innerNode></innerNode> <last_name>Smith</last_name> <first_name>John</first_name> </lead> and what i've come up with so far is this, but i don't even know if i'm on the right track: Code: [Select] $last_name = $_REQUEST['l_name']; $first_name = $_REQUEST['f_name']; $url = "http://url.com/leads"; $post_string = '<?xml version="1.0" encoding="UTF-8"?> <lead> <innerNode></innerNode> <last_name>'.$last_name.'</last_name> <first_name>'.$first_name.'</first_name> </lead>'; $header = "POST HTTP/1.0 \r\n"; $header .= "Content-type: text/xml \r\n"; $header .= "Content-length: ".strlen($post_string)." \r\n"; $header .= "Content-transfer-encoding: text \r\n"; $header .= "Connection: close \r\n\r\n"; $header = $post_string; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 4); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header); $data = curl_exec($ch); if(curl_errno($ch)) { print curl_error($ch); } else { echo "yay"; curl_close($ch); } i'm being told "should return a response.xml with either a success or failure post status." which is confusing me can someone help a bit? thanks very much... GN Is there anyway to do this: my form is posting to self, then checking login creds. if they are incorrect it spits out "invaild bla bla" but if they are correct send them to a different page? here is the short version of what I have. if(isset($_POST['submit'])) { //check inputs vs db if ($check) { header("Location: http://". $_SERVER['SERVER_NAME']."/include/process_renew.php"); } else { echo "<font color='red'>Username or Password did not match.</font> <br /><br />"; } } } I tested it using echo first and it worked fine then replaced the echo with header and now when I submit it just refreshes the page. is this not possible? I have this code with clears the input box onclick... Code: [Select] <input type="text" name="username" value="Username" onclick="value=''"/> however is there any way to use php to get the value of username, before its posted? that way i can make it so it only clears if the value of username is "username" can anyone help me as to whay I get this error: Problem with the query: INSERT INTO options (item_id, option ) VALUES('1', 'hi' ) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'option ) VALUES('1', 'hi' )' at line 1 with this code: Code: [Select] foreach($_POST["user"] AS $key => $val) { $user = $val; $id1 = $_POST['id1'][$key]; $sql = "INSERT INTO options (item_id, option ) VALUES('$id1', '$user' )"; $rs = mysql_query($sql) or die ("Problem with the query: $sql <br />" . mysql_error()); } Code: [Select] <input type="checkbox" name="yes" id="checkme" /><div id = "extra"> <div id="user"> Enter User Names:<br> <input type="text" name="user[]"/><br></div> <div id="add_user" style="display: none;"><input type="text" name="user[]"/> the code is in a form whose method = "post". i have failed to echo $r_in. i eed help on this. $lowest_time = 30 - 14; $adder = 2*5*9; echo '<table width="526" border="0"><tr> <td width="169"> <input type="text" name="$r_in" value="'.$lowest_time.'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="$r_out" value="'.$adder.'" style="width:169px" readonly="readonly" class="text_non_color"/></td> </tr></table>'; Hi, i have written a form that uses 3 dropdown boxes, one of them being populated from a database. The form code is as follows; Code: [Select] <form id="pointsForm" name="pointsForm" method="post" action="points-engine.php"> <select name="car" id="car"> <?php // result of car name collection $result = mysql_query ($query); //Array stored in $cars while($cars=mysql_fetch_array($result)){ //option values added by looping through array echo "<option value=$cars[id]>$cars[carName]</option>"; } ?> </select> <select name="season" id="season"> <option value="low">Low season</option> <option value="mid">Mid season</option> <option value="high">High season</option> <option value="peak">Peak season</option> </select> <select name="period" id="period"> <option value="day">One day</option> <option value="weekend">Weekend</option> <option value="week">One week</option> </select> <input type="submit" name="Submit" value="Submit" /> </form> which posts to; Code: [Select] <?php $car=$_POST['car']; echo $car; $season=$_POST['season']; echo $season; $period=$_POST['period']; echo $period; ?> The initial form code is working fine, the car field is being populated from the database. My problem is the post value for car isn't working... points-engine.php is echoing $season & $period fine but not $car can anyone tell me why? many thanks Richard Hi guys, I have a list box. say the code is Code: [Select] <select name="drop1" id="Select1" size="4" multiple="multiple"> <option value="1">item 1</option> <option value="2">item 2</option> <option value="3">item 3</option> <option value="4">item 4</option> <option value="0">All</option> </select> The user will select few items. How do i capture the data through the "POST" method. Code: [Select] $data = $_POST['drop']; would not work coz there is an array if data. Can any one help or point me in the right direction? Thanks in advance You guys helped me create a function to gather information for my database. Now I need some help with posting that information. Function code and Form: <?php include("opendatabase.php"); ?> <?php function createMatchup($week, $game) { $query1 = "SELECT team_name FROM schedule, teams WHERE schedule.week_id = $week AND schedule.game_id = $game AND schedule.A_team = teams.team_id"; $query2 = "SELECT team_name FROM schedule, teams WHERE schedule.week_id = $week AND schedule.game_id = $game AND schedule.H_team = teams.team_id"; $result1 = mysql_fetch_assoc(mysql_query($query1)); $result2 = mysql_fetch_assoc(mysql_query($query2)); $output = " <input type=\"text\" size = \"3\" name=\"w$weekg$gameA\"> {$result1['team_name']} vs. {$result2['team_name']} <input type=\"text\" size = \"3\" name=\"w$weekg$gameH\">"; return $output; } $game1 = createMatchup(1, 1); $game2 = createMatchup(1, 2); $game3 = createMatchup(1, 3); $game4 = createMatchup(1, 4); $game5 = createMatchup(1, 5); $game6 = createMatchup(1, 6); $game7 = createMatchup(1, 7); $game8 = createMatchup(1, 8); $game9 = createMatchup(1, 9); $game10 = createMatchup(1, 10); $game11 = createMatchup(1, 11); $game12 = createMatchup(1, 12); $game13 = createMatchup(1, 13); $game14 = createMatchup(1, 14); $game15 = createMatchup(1, 15); $game16 = createMatchup(1, 16); mysql_close($con); ?> <form action="insert_spreads.php" method="post"> <?php echo $game1; ?> <br> <?php echo $game2; ?> <br> <?php echo $game3; ?> <br> <?php echo $game4; ?> <br> <?php echo $game5; ?> <br> <?php echo $game6; ?> <br> <?php echo $game7; ?> <br> <?php echo $game8; ?> <br> <?php echo $game9; ?> <br> <?php echo $game10; ?> <br> <?php echo $game11; ?> <br> <?php echo $game12; ?> <br> <?php echo $game13; ?> <br> <?php echo $game14; ?> <br> <?php echo $game15; ?> <br> <?php echo $game16; ?> <br /><br /> <input type="Submit" value="Submit Spreads"> </form> I'm wondering if I can use this code for posting to the database (insert_spreads.php): <?php header("Location: admin_schedule.php"); include("opendatabase.php"); $w$weekg$gameA=("$_POST['w$weekg$gameA']"); $w$weekg$gameH=("$_POST['w$weekg$gameH']"); $sql=" UPDATE schedule SET A_pt_spread= '$w$weekg$gameA',H_pt_spread= '$w$weekg$gameH' WHERE week_id = '$week' AND game_id = '$game'; $result = mysql_query($sql) or die(mysql_error().$sql); mysql_close($con) ?> Thanks for helping. i am basically trying to retrieve the response of a chatbot from mysql database with query below. As i run script i don't get any error from the server but it seems the post doesn't take $data2 which is an array that includes the keys "user_id" and "text" that are normally accepted (eg: $dmessage->post('direct_messages/new/wrap_links=true', 'text'->'example', '12345'); As result of the above i can't post to Twitter the chatobot response as the recipient (my other twitter account) doesn't get the answer...what do you think? Code: [Select] include_once ('connect.php'); connect_to_database(); $query2 = mysql_query ("SELECT response FROM conversation_log WHERE id = (SELECT MAX(id) FROM conversation_log)") or die (mysql_error()); $row = mysql_fetch_row($query2); $response = $row[0]; //this is the array with the parameters to be used to send bot responses via Twitter API. It normally takes $data2 = array("text"=>"$response" , "user_id"=> "$userid"); //this modifies the array values with response e userid fields $data2["text"] = "$response"; $data2["user_id"] = "$userid"; require_once('config_oauth.php'); // includes the applications Oauth keys require_once($_SERVER['DOCUMENT_ROOT'].'Program-O/gui/xml/oauth/twitteroauth.php'); //Full path to twitteroauth.php library $dmessage = new TwitterOAuth($consumer_key,$consumer_secret, $oAuthToken, $oAuthSecret); // create new instance with the credentials //sends the bot response via Twitter API by going through the array $data2 $dmessage->post('direct_messages/new/wrap_links=true', $data2); I am working on a PHP/MySQL authorization script. The script seems to work initially, but when I try to Login and post the Form ( echo '<form method="post" action=authorize_1.php">'; echo '<table>'; echo '<tr><td>Userid:</td>'; echo '<td><input type="text" name="userid"></td></tr>'; echo '<tr><td>Password:</td>'; echo '<td><input type="password" name="password"></td></tr>'; echo '<tr><td colspan="2" align="center">'; echo '<input type="submit" value="Log in"></td></tr>'; echo '</table></form>'; ) Internet Explorer returns the error that the page is not found.... but I am using one .php file for the authorization so I am sure the page is found because i can see the Login portion. Any ideas as to what is going wrong? How can I post this variable $healspell when I already have an echo within a php? Here's what I have: echo '<p>You cast Nature\'s Cure (Recovered <?=$healspell?>)</p>'; It's not printing anything out at the moment, obviously, and if I just put $healspell, it just echos out: $healspell. Thanks! might have it nevermind. I've tried this: <?php $xsblock = $_SERVER['HTTP_REFERER']; $url = "testchan"; $pos = strpos($xsblock, $url); if ($pos == false) { die(); } else { echo "content content content content content content content content"; } ?> How can I do this correctly? Thanks in advance! I have an issue with my script, the date for some reason stopped posting after I changed the format in the date() section, I wanted it to post so it shows month-day-year, and it seems for some reason all it accepts is Y-m-d... Can someone help me out here please? Code: [Select] <?php require_once('connectvars.php'); if (isset($_POST['submit'])) { // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $PO_Date = date('MM "/" DD "/" YY',strtotime($_POST['PO_Date'])); $query = "INSERT INTO ncmr (PO_Date) VALUES ('$PO_Date')"; mysqli_query($dbc, $query); // Confirm success with the user echo '<p>The date have been successfully entered</p>'; mysqli_close($dbc); // Clear the score data to clear the form $PO_Date = ""; } echo'<form form id="all" method="post">'; echo '<div id="abd"><span class="b">On: </span><input type="text" name="Added_By_Date" value="" /></div>'; echo '<div id="button"><input type="submit" value="Submit Edits" name="submit" /></div>'; echo '</form>' ?> hello, i have a while loop that displays multiple tables of data depending on how many are in the database... i have a link if you click it will redirect to another page that prompts you to save an xls file with the table data... this was all working for me before when i had the while loop display rows of data in one table...well i decided that i would like the while loop to display a separate table each time... when i changed it... the xls file only shows one table of data... how can i set up so it will export all tables of data... is there some kind of loop i can set up for it to append the tables?? i have the table data all in a variable $table which i put into a hidden form field that redirects to the xls export page.... any help is appreciated... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Admin</title> </head> <body> <?php $sql= mysql_query("SELECT * FROM programs") or die (mysql_error()); while($row = mysql_fetch_array($sql)){ $table = "<table border='1' width='600' style='border-collapse:collapse;'>" . "<th colspan='4'>Programs</th>" . "<tr>" . "<td>ID</td>" . "<td>Views</td>" . "<td>Enabled</td>" . "</tr>"; $prog_titles = $row['titles']; $prog_titles = explode(',' , $prog_titles); $table .= "<tr>" . "<td>".$row['id']. "</td>" . "<td>".$row['views']. "</td>" . "<td>".$row['enabled']. "</td>" . "<td></td>" . "</tr>" . "<tr>" . "<td>Title ID</td>" . "<td>Name</td>" . "<td>Description</td>" . "<td>Image</td>" . "</tr>" ; foreach ( $prog_titles as $title ) { $sql2= mysql_query("SELECT * FROM titles WHERE title = '$title' "); $row2 = mysql_fetch_array($sql2); $table .= "<tr>" . "<td>" . $row2['id'] . "</td>" . "<td>" . $row2['title'] . "</td>" . "<td>" . $row2['description'] . "</td>" . "<td>". "<img width='50px' src='images/" . $row2['img'] . "'/></td>" . "</tr>" ; } // close foreach $table .= "</table>"; echo $table; echo "<br /><br /><br />"; } // close while ?> <br /> <br /> <FORM action="export.php"> <INPUT type="submit" value="Export to XLS"> <INPUT type="hidden" value="<?php print $table;?>" name="export"> </FORM> </body> </html> i am making a website where i can submit films but i am confuse to understand the structure of that where people can also submit their views and i can diferent link of diffrent companiess for example i have some example http://tv.desitvforum.net/index.php?option=com_content&task=view&id=77865&Itemid=86 http://www.funbolo.com/more.asp?itemCode=1916 this type of page that i can easily insert links and their title and images on that page there is also one problem every time become different links of different sites in different counting so that's why m more confuse ho to set data base structure for that and how add these all details from panel and people can also post comment on that well thats simple but my bug problem is structure for this aNy Body in structure I have a database in which i store articles that contain all type of special characters including slashes, single quotes, double quote etc. Previously it was working fine, but now after the updating the xampp, things are not going as usual. I insert are articles using following code $query = "INSERT INTO `articles` (`source`, `heading`, `description`, `catagory`, `detail`, `date`, `timestamp`) values ('$source', '$heading', '$desc', '$catagory', '$detail', '$date', '$timestamp')"; Error I am getting is Error Running query 1You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's economy and emphasized that international community should provide its complet' at line 2 Can anybody tell me whats wrong with my script? |