PHP - Hidden Input Doesn't Change Serverside When Updated In The Client
I am trying to set the hidden input in the javascript but it doesn't set it in the php. This is the form with the hidden input. It corresponds to a field in the database table with the name of draggables. <form method="post" accept-charset="utf-8" id="myForm2" action="/mealplans/add"> <input type="hidden" name="draggables" id="drag12"/> <button id="myId" type="submit">Submit Form</button> </form> This is where I change the value in the javascript: if(data == "draggable3"){ alert("data " + data); var x = document.getElementById("drag12").value; x = "draggable3"; alert(x); } //end if
I've also tried getElementsByName but that didn't work either. var y = document.getElementsByName("draggables").value; //only changes it on the client This is actually a cakephp site but this problem is with the PHP so I am publishing it here. Similar TutorialsIs there something wrong with this query? elseif($_POST["titlee"] && $_POST["contente"]) { $titlee = $_POST['titlee']; $contente = $_POST['contente']; $to = $_POST['edit']; mysql_query("UPDATE custom_pages SET title='$titlee' AND content='$contente' WHERE id='$to'"); echo '<div class="post"> <div class="postheader"><h1>Updated</h1></div> <div class="postcontent"> <p>Your custom page has been updated.</p> </div> <div class="postfooter"></div> </div> '; } Hi there,
Apologies if this is in the wrong section, not sure what would cover it aha
I have a client who would like to be able to update her photos in the gallery weekly, and possibly update any text on the site herself (description etc). What is the best way to go about this? She used a site builder to get it up and running, but I don't have access to the host, so I don't have access to databases or know if they allow PhP.
Would an admin panel be the best way about this?
If so, would anyone mind talking me through a rough step-by-step of the process?
Hi Guys, Appreciate any help here please... Basically I want to hide some inputs on my registration page and populate them will default values. Everything works okay, apart from the input below: Code: [Select] <input type="hidden" name="seek_location" value="Anywhere"> When I use the above, the MYSQL database field for seek_location is left empty... I've noticed that the code below pulls the location into a dropdown list. You know the kind of thing, Australia, UK, USA etc etc: Code: [Select] $seek_location = $wcr[$seek_location]; Code: [Select] <? $p=0;asort($wcr);reset($wcr); while (list ($p, $val) = each ($wcr)) { echo '<option value="'.$p.'">'.$val; } ?> So, all I want to do is have: Code: [Select] <input type="hidden" name="seek_location" value="Anywhere"> Populate seek_location with Anywhere Any help appreciated Thanks Rob This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=342456.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=317004.0 i have the following code: <li>Have you read the <?php echo link_to('FAQ','util/faq') ?> ? <select id="yesnolist" onChange="getChoice(this.value)"> <option value="yes" selected="selected">Yes</option> <option value="no">No</option> </select> </li> <input type="hidden" name="text" size=30 id="yesandno"> <?php if ($_GET['yesandno'] == "no") { echo "anything!!!!!!!!!!!!!!!!!!!"; } ?> then my java script for getCoice(): function getChoice(val) { yesNo = new Array("Yes", "No"); var getsel = document.contactus.yesnolist.value; var e = document.getElementById("yesnolist"); var strUser = e.options[e.selectedIndex].value; document.contactus.yesandno.value = strUser; alert(document.contactus.yesandno.value); return strUser; } my alert will gove yes or no depending on what i chose in the dropdown but HOWCOME it does not go into the if ($_GET['yesandno'] == "no") ???? please help??? hidden input field type doesnt display the full value i get from table, say if it is a first name and last name i get only the first name. here is my input field echo "<input type=hidden name=proid value=$result_row[project_id]></include>"; echo "<input type=text value=$result_row[project_name] readonly></include>"; my sql query returns the full name but when i input into the text field it returns an incomplete project name like say if it is fans of soccer, i just get the value "fans" in my display..... Just curious, how would you go about rendering and storing this in a database. For example a simple small maze.
With each keypress, the user is moved up,down,left,right like 1 inch. (1 block). Which is easy to do with jquery, etc. But how would go about storing the data in a databse (can update the position per update or using websockets), but essentially so maphacks are impossible and everything is saved/read from the server.
Would the storage data be something like [0,0,0,1,0,0,1,1,1,1,0,1] I imagine or what?
Edited by Monkuar, 01 December 2014 - 09:32 PM. Hello All,
I am trying to write an code on server-side when the request come from the url containing id as parameter and based upon the parameter process and send the response.
can you please provide any reference for this or sample code?
Thanks & Regards,
ShailShin
The PHP code sends me an email from the server, but the user input is empty or "blank". I only receive: "From: \ Email: \ Subject: \ Message: " and that's it. How do I fix my PHP and/or HTML code to receive user input from the form? Attached is my existing HTML and PHP code that doesn't send me any "user input" from the form. Thanks to anyone who can help!!
Hello everyone, I'm simply trying to move a character on a map. When the user selects a direction and a speed the character is moved on the map. Simple right? I've tried a few methods of doing this to no avail. I will list the different things I've tried. Code: [Select] <form action="index.php?do=move" method="post"> <select name="direction"> <option value="north" selected>North</option> <option value="south">South</option> <option value="east">East</option> <option value="west">West</option> </select> <select name="speed"> <option value="move0" selected>Feet +0</option> <option value="move1">Goat +1</option> <option value="move2">Donkey +2</option> <option value="move3">Cow +3</option> <option value="move4">Pig +4</option> <option value="move5">Horse +5</option> </select><br /> <input type="submit" name="post" value="Move"> </form> if (isset($_POST["post"])) { if (isset($_POST["direction"]) == "north") {$latitude++; if ($longitude > $controlrow["gamesize"]) { $latitude = $controlrow["gamesize"]; } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move1")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*2)) { $latitude = ($controlrow["gamesize"]*2); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move2")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*3)) { $latitude = ($controlrow["gamesize"]*3); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move3")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*4)) { $latitude = ($controlrow["gamesize"]*4); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move4")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*5)) { $latitude = ($controlrow["gamesize"]*5); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move5")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*6)) { $latitude = ($controlrow["gamesize"]*6); } } elseif (isset($_POST["direction"]) == "south") {$latitude--; if ($latitude < ($controlrow["gamesize"]*-1)) { $latitude = ($controlrow["gamesize"]*-1); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move1")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-2)) { $latitude = ($controlrow["gamesize"]*-2); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move2")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-3)) { $latitude = ($controlrow["gamesize"]*-3); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move3")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-4)) { $latitude = ($controlrow["gamesize"]*-4); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move4")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-5)) { $latitude = ($controlrow["gamesize"]*-5); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move5")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-6)) { $latitude = ($controlrow["gamesize"]*-6); } } elseif (isset($_POST["direction"]) == "east") {$longitude++; if ($longitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move1")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*2)) { $longitude = ($controlrow["gamesize"]*2); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move2")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*3)) { $longitude = ($controlrow["gamesize"]*3); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move3")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*4)) { $longitude = ($controlrow["gamesize"]*4); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move4")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*5)) { $longitude = ($controlrow["gamesize"]*5); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move5")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*6)) { $longitude = ($controlrow["gamesize"]*6); } } elseif (isset($_POST["direction"]) == "west") {$longitude--; if ($longitude < ($controlrow["gamesize"]*-1)) { $longitude = ($controlrow["gamesize"]*-1); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move1")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-2)) { $longitude = ($controlrow["gamesize"]*-2); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move2")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-3)) { $longitude = ($controlrow["gamesize"]*-3); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move3")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-4)) { $longitude = ($controlrow["gamesize"]*-4); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move4")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-5)) { $longitude = ($controlrow["gamesize"]*-5); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move5")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-6)) { $longitude = ($controlrow["gamesize"]*-6); } } } Also if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move0")) { $latitude++; if ($latitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move1")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*2)) { $latitude = ($controlrow["gamesize"]*2); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move2")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*3)) { $latitude = ($controlrow["gamesize"]*3); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move3")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*4)) { $latitude = ($controlrow["gamesize"]*4); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move4")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*5)) { $latitude = ($controlrow["gamesize"]*5); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move5")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*6)) { $latitude = ($controlrow["gamesize"]*6); } } } } } } } Any help would be appreciated. If you need more info just ask. Thanks, Waffles :-\Have been reading a few places about how to set php.ini file to be able to use MySQL on my Yahoo website. But am also warned to avoid tampering needlessly with registry. So I need an absolute precedure, with port 465, I also know. Embarassing how long this has taken me to find some of this out! Thanks, Yshua This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=357414.0 I wish to create validation rules once which are used both on the client and on the server.
For instance, I will start off with the following PHP object:
stdClass Object ( [rules] => stdClass Object ( [email] => stdClass Object ( [required] => 1 [email] => 1 [remote] => stdClass Object ( [url] => check-email.php [type] => post [data] => stdClass Object ( [username] => function() {return $( '#username' ).val();} ) ) ) ) [messages] => stdClass Object ( [email] => stdClass Object ( [required] => an email is required ) ) )When the edit page is downloaded to the client, I will include this object in some format suitable to the client. The client will then use the jQuery Validation plugin (http://jqueryvalidation.org/) along with the validation object, and client side validate the page. When the form passes client side validation and is uploaded, PHP will use the same validation object to serverside validate the form (I have this part working as desired). My question is how should I pass this data to the client? Originally, I would just use PHP to write some JavaScript. exit('var myObj='.json_encode($myObj));Note that when I json_encode the object, the value of $myObj->rules->email->remote->data->username is a string with quotes around it, however, I can easily use PHP to strip these tags before sending it to the client. As Jacques1 pointed out in http://forums.phpfre...ascript-client/, I should never ever use PHP to generate JavaScript, and should use AJAX to download the JSON directly. I tried doing the later, but found that a callback function could not be included in the JSON. Please advise on the best way to accomplish this. Thank you I have a search function in php where the text characters are matched to characters in a tables field--- works perfectly.... I need to make the input box have a droplist of words from database, this is also easy for me to do. the problem here is there is no definitive value! the options list always outputs a blank in the url--- its supposed to search a matching value and then output the matching value to url... Here is the droplist code: $output['RATESTITLE']='<input class="inputbox" type="text" size="24px" name="ratestitle" value="'.$sch->filter['ratestitle'].'" onfocus="if (this.value ==\''.$output['LANGUAGE_SEARCH_RATESTITLE'].'\') {this.value = \'\'}" />'; this outputs a input text box--- i want to have a droplist of options to populate this text box... If you must know this is the third day im at it... What's the best way to display when a page was last edited/modified? this is the script for viewing the data in edit mode <tr> <td width="67" height="24"><select name="qualifi"> <option selected="selected">None</option> <?php $qry=mysql_query("select * from qualification"); while($obj=mysql_fetch_array($qry)) { ?> <option value="<?php echo $obj[0]; ?>"<?php if($obj[0]==$qualifi) echo("selected"); ?>><?php echo $obj[1]; ?></option> <?php } ?> </select> </td> <?php echo"<td width='301'><input name='board' type='text' size='50' value='$board'/></td>"; echo"<td width='60'><input name='start' type='text' size='10' value='$start'/></td>"; echo"<td width='60'><input name='end' type='text' size='10' value='$end'/></td>"; echo"<td width='60'><input name='percentage' type='text' size='10' value='$percentage'/></td> </tr>"; } ?> </table> and the update query is like //qualification if($_SESSION[empcode]!="") { if($_SESSION[qualifi]!="None") { mysql_query("update HRMEMPQUAL set EMPCODE='$_SESSION[empcode]',QUALCODE='$_SESSION[qualifi]',BOARD='$_SESSION[board]',FROMYEAR='$_SESSION[start]',TOYEAR='$_SESSION[end]',MARK_PERCENT='$_SESSION[percentage]' where EMPCODE='$_SESSION[empcode]'"); } } how can i save all the data correctly while any change is take place...their are 3 rows of data.only the last fled data is updated all the 3 rows Hi. I am trying to figure out the best approach to pull THE most recent record for display, and ONLY the most recent one. I am really not sure how to go about doing this. Ive just started into stored procedure programming and php, but havent found anything yet on this one. Thanks. I have a script to update certain rows that contain certain data in them. Here is the code: if ($_POST['newstype'] == "1") { $query = mysql_query("SELECT * from `news` WHERE type='1'"); if (mysql_num_rows($query) == 1) { mysql_query("UPDATE `news` SET type = '2' WHERE type = '1' ORDER BY `news`.`dtime` ASC LIMIT 1") or die(mysql_error()); } else { echo "did not edit main news"; } } elseif ($_POST['newstype'] == "2") { $query = mysql_query("SELECT * from `news` WHERE type='2'"); if (mysql_num_rows($query) == 3) { mysql_query("UPDATE `news` SET type = '3' WHERE type= '2' ORDER BY `news`.`dtime` ASC LIMIT 1") or die(mysql_error()); } else { echo "did not edit recent news"; } } elseif ($_POST['newstype'] == "3") { $query = mysql_query("SELECT * from `news` WHERE type='3'"); if (mysql_num_rows($query) == 3) { mysql_query("UPDATE `news` SET type = '4' WHERE type= '3' ORDER BY `news`.`dtime` ASC LIMIT 1") or die(mysql_error()); } else { echo "did not edit old news"; } } else { echo "didnt update anything!"; } Here is my database structure. Why is it not updating it and always saying Did not edit main/recent/old news. i am a beginerr in php.. and here is my code..which shows error in the querry line.. erro goes like this Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\restafinal\process_edit_page.php on line 56 and code goes like this.. echo part works well...that query line is the error line..please tell me whats the problem... Code: [Select] <?php //$id=$_GET["id"]; $id= $_GET['id']; $menu_name= $_POST['menu_name']; $position= $_POST['position']; $visible= $_POST['visible']; $note= $_POST['note']; $content= $_POST['content']; //echo part works well.. echo "menu_name"; echo $menu_name; echo "<br/>"; echo "position"; echo $position; echo "<br/>"; echo "visible"; echo $visible; echo "<br/>"; echo "note"; echo $note; echo "<br/>"; echo "id"; echo $id; echo $content; [b]$result = mysql_query(UPDATE page SET note =$note, nevigation = $menu_name WHERE id = $id,$connection)[/b] // test to see if the update occurred if (mysql_affected_rows() == 1) { // Success! } else { $message = "The page could not be updated."; $message .= "<br />" . mysql_error(); } ?> |