PHP - Stop Xs Posting?
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! Similar Tutorialsi'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 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>' ?> 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 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. 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 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? 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[]"/> 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! 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); 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 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? 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" 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>'; 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? might have it nevermind. I'm trying to figure out a way to post data directly to a URL. For example: <?php if (isset($_POST["pass"]) && ($_POST["pass"]=="$password")) { echo "You did it"; ?> <?php } else { echo "<form method=\"post\"><p align=\"left\">"; echo "<input name=\"pass\" type=\"text\" size=\"25\" maxlength=\"40\"><input value=\"Enter Pass\" type=\"submit\"></form>"; exit; } ?> Let's assume $password is 'password'. Why can't I simply pass the information through the URL to access the page with something like this: Code: [Select] http://mypage.com/the-same-page.php?pass=password ok so im wondering if you all could prob fix this code its not working and when "meta"when it refreshes the page nothing deletes Code: [Select] <?php $host="localhost"; // Host name $username="username"; // Mysql username $password="password"; // Mysql password $db_name="database name"; // Database name $tbl_name="table name"; // Table name // below was a replie from forums. it made alot of problems// foreach($_POST['checkbox'] AS $ID) { $values[] = '\''.intval($ID).'\''; } $values = implode(' , ',$values); $myQuery = "DELETE FROM $tbl_name WHERE id IN ($values)"; if(mysql_query($myQuery)) { header('Location: delete_multiple.php'); } else { echo 'Query failed: "'.$myQuery.'"'; } // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <style> /*table affects look of the whole table look */ table { margin-left: auto; margin-right: auto; border: 1px solid #330000; border-collapse:collapse; width:70%; border-width: 5px 5px 5px 5px; border-spacing: 1px; border-style: outset outset outset outset; border-color: #330000 #330000 #330000 #330000; border-collapse: separate; background-color: #330000; #800517 f535aa #330000 school color #9A0000 school color2 #991B1E school color3 #CCCC99 school color4 #9A0000 } /*th is table header */ th { text-align: left; height: 2.5em; background-color: #330000; color: #FC0; font-size:1.5em; } /*td is table data or the cells below the header*/ td { text-align: left; height:1.0em; font-size:1.0em; vertical-align:bottom; padding:10px; border-width: 5px 5px 5px 5px; padding: 8px 8px 8px 8px; border-style: outset outset outset outset; border-color: #9A0000 #9A0000 #9A0000 #9A0000; background-color: #CCCC99; -moz-border-radius: 0px 0px 0px 0px; } </style> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Pick Which Rows you want to delete, Then press delete.</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> <td align="center" bgcolor="#FFFFFF">delete</td></tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php // Check if delete button active, start this // edited if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">"; } } mysql_close(); ?> </table> </form> </td> </tr> </table> this is whats wrong with it could i get some help? Warning: Invalid argument supplied for foreach() in /home/sumersadl/public_html/testfile/delete_multiple.php on line 8 Warning: implode() [function.implode]: Invalid arguments passed in /home/sumersadl/public_html/testfile/delete_multiple.php on line 12 Warning: mysql_query() [function.mysql-query]: Access denied for user 'root'@'localhost' (using password: NO) in /home/sumersadl/public_html/testfile/delete_multiple.php on line 16 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/sumersadl/public_html/testfile/delete_multiple.php on line 16 Query failed: "DELETE FROM test_mysql WHERE id IN ()" I'm not much of a PHP programmer so please excuse the mess but I'm having a problem with some code. I am able to successfully build a table and assign values to radio buttons based one information in a database. The problem comes when I want to update the database when someone changes a radio button. Everthing works up until the foreach statment. Nothing in the database is being updated, if I replace the sql statement with echo $v; all I get is the word Submit so it's like the rest of the values aren't being included in the form. <link href="css/demo.css" rel="stylesheet" type="text/css"> <?php session_start(); // dBase file include "dbconfig.php"; if (!$_SESSION["valid_user"]) { // User not logged in, redirect to login page Header("Location: index.php"); } //Grab GUID passed in the URL $guid=$_GET['guid']; // Create query for student name $sql = "SELECT FirstName, LastName FROM Students where GUID ='". $guid . "'"; // Run query $result = mssql_query($sql); $row= mssql_fetch_assoc($result); // Member only content //Title and main page information echo "<div align=\"center\"><p><img src=\"images/EFCTS Logo.jpg\" width=\"600\" height=\"144\" /></p><h1>OCAP DATABASE</h1></div>"; echo "<p><a href=\"logout.php\">Logout</a></p>"; //Build sortable table of student data. echo "<table id=\"test1\" class=\"sortable-onload-3-reverse rowstyle-alt no-arrow\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"; //query database for table information $SQLcommand = "SELECT convert(varchar(36), StudentGUID) as StudentGUID, CompetencyLevel, CompetencyName, CompetencyID, Category, convert(varchar(36), CompetencyGUID) as CompetencyGUID FROM VW_StudentSkills WHERE StudentGUID ='". $guid ."'"; $SQLresult = MsSQL_QUERY($SQLcommand); //Continue building table echo "<caption>".$row[FirstName]." ".$row[LastName]."</caption>"; echo "<th style=\"-moz-user-select: none;\" class=\"sortable-numeric fd-column-0\"><a title=\"Sort on \"Competency ID\"\" href=\"#\">Competency ID</a></th>"; echo "<th style=\"-moz-user-select: none;\" class=\"fd-column-1 sortable-text reverseSort\"><a title=\"Sort on \"Catagory\"\" href=\"#\">Catagory</a></th>"; echo "<th style=\"-moz-user-select: none;\" class=\"fd-column-2 sortable-text reverseSort\"><a title=\"Sort on \"Competency Name\"\" href=\"#\">Competency Name</a></th>"; echo "<th style=\"-moz-user-select: none;\" class=\"sortable-numeric fd-column-3\"><a title=\"Sort on \"Competency Level\"\" href=\"#\">Competency Level</a></th>"; echo "</tr></thead>"; //Set variables for radio buttons $a=""; $b=""; $c=""; $d=""; //count the number of rows returned $count=mysql_num_rows($SQLresult); //Start form echo "<form name=\"form1\" method=\"post\" action=\"".$_SERVER['REQUEST_URI']."\">"; $groupnum = 0; //Build table with SQL data while($row2=mssql_fetch_array($SQLresult)) { //find the competency level $complevel = $row2[CompetencyLevel]; if($complevel=="1") $a="checked"; if($complevel=="2") $b="checked"; if($complevel=="3") $c="checked"; if($complevel=="4") $d="checked"; //build the table echo "<tr class=\"\"><td>".$row2[CompetencyID]."</td><td>".$row2[Category]."</td>"; echo "<td>".$row2[CompetencyName]."</td>"; echo "<td class=\"lft\"><input type=\"radio\" name=\"".$row2[CompetencyID]."\" value=\"1\"".$a."> 1"; echo "<input type=\"radio\" name=\"".$row2[CompetencyID]."\" value=\"2\"".$b."> 2"; echo "<input type=\"radio\" name=\"".$row2[CompetencyID]."\" value=\"3\"".$c."> 3"; echo "<input type=\"radio\" name=\"".$row2[CompetencyID]."\" value=\"4\"".$d."> 4"; $idarray[]=$row2[CompetencyGUID]; echo "</td></tr>"; $groupnum++; //clear the variables $a=""; $b=""; $c=""; $d=""; } echo "</tbody>"; echo "<input type=\"submit\" name=\"Submit\" value=\"Submit\">"; echo "</form></table>"; echo "<script type=\"text/javascript\" src=\"javascript/tablesort.js\"></script>"; if($_POST['Submit']) { echo"submit button detected"; foreach($_POST as $k=>$v) { if($k!="Submit") { $sqlUpdate = "UPDATE DATA SET COMPETENCYLEVEL = '".$v."' WHERE COMPETENCYGUID = '".$idarray."' AND STUDENGUID = '".$guid."' "; $resultUpdate = mssql_query($sqlUpdate); } } } if($resultUpdate) { print_r ($_POST); echo $resultUpdate; echo $sqlUpdate; } else { echo "Your entry is not completed at this time............."; echo $sqlUpdate; echo $resultUpdate; } // Display Member information //echo "<p>User ID: " . $_SESSION["valid_id"]; //echo "<p>Username: " . $_SESSION["valid_user"]; //echo "<p>Logged in: " . date("m/d/Y", $_SESSION["valid_time"]); ?> I have a db table with 1500 street names inside - id, tfare, ptown, pcode, area. The 'area' column is specific to the company i work for and each street belongs to an 'area' number defined by the company. Currently each area is '0' - unassigned. The company areas are numbered 1 - 18. I need to list each street (LIMIT 10 at a time), and have an input box for the area to be edited and saved. The following code works perfectly well when dealing with 1 record at a time (LIMIT 0, 1), but breaks when i change the LIMIT to 10. I'm trying to show the dinosaur management that we need to upgrade our paper, yes, paper system to computers. I'm a transport manager, but in my spare time since 2004 I'm fluent in HTML and CSS, but only in the last few months really decided to give PHP and MySQL a *real* go. I'm 'guessing' I need to look into arrays for this to work? I've tried searching about but I dont even know how to articulate what i need to search for, so I have to publicly ask for help via this long winded post, sorry Here is my code: <?php include($_SERVER['DOCUMENT_ROOT'].'/!SYSTEM/bootstrap.php'); if(isset($_POST['savearea'])) { $id = $_POST['hideID']; $area = $_POST['area']; $sql = "UPDATE bmth_streetindex SET area='$area' WHERE id='$id'"; if ($query = mysql_query($sql)or die(mysql_error())) { print "saved ???"; } } // grab data from bmth street index where the area is = 0 (which means its area is un-assigned) $sql = "SELECT * FROM bmth_streetindex WHERE area='0' LIMIT 0, 10"; $rs = mysql_query($sql) or die(mysql_error()); print $HTML::form('action="" name="inputAreaForm" method="POST"')."\n\n"; // 'while' thru and print them 1 at a time while($row = mysql_fetch_array($rs)) { $id = $row['id']; $tfare = $row['tfare']; $ptown = $row['ptown']; $pcode = $row['pcode']; $area = $row['area']; $urlQ = $tfare. ", " .$ptown. ', ' .$pcode; print "<div>\n"; print "\n<input type=\"hidden\" name=\"hideID\" value=\"$id\">"; print "\n[$id] $tfare, $ptown, $pcode "; print "\nArea <input type=\"text\" name=\"area\" value=\"$area\" />"; print "\n<input type=\"submit\" name=\"savearea\" value=\"Save Area\">"; print "\n<a href=\"http://www.google.com/maps?q=$urlQ&hl=en&ie=UTF8&z=17\" target=new>SHOW ON MAP</a>"; print "\n<>\n<hr>\n\n"; } print $HTML::endForm(); ?> Thank you for taking the tie to read this, I hope someone can point me in the right direction for what i need to look into making this work Bad title, I know. What I mean is I have a code that shows a pop-up error message if you try to post with a username someone else has. Well, I use this code for my user/pass/message fields: $user = preg_replace("/[^A-Z a-z0-9]/", "", $_POST['user']); $password = preg_replace("/[^A-Za-z0-9]/", "", $_POST['password']); $message = preg_replace("/[^A-Za-z0-9]/", "", $_POST['message']); What that does is, if you post with, say, a less than or greater than sign, or some other whack character, it makes the field blank for whichever field(s) you enter other characters into. So really, when someone posts on my forums with a character I do not want them to use in their user/message, it makes the message completely blank, no matter what other allowed characters are used, and the same with the username...so the post will show up without a poster. My question is, what is a code to use so a pop-up box would show up instead of letting the post go through and post blanks? Doesn't even have to be a pop-up box, just something to say to the user, "Hey, you can't use (insert disapproved character(s) here)" and to have the post not go through. |