PHP - Need Help Creating A Server Side Script To Save Input From Html Forms
Hi,
I have made a basic html site and it has two forms on it. I have the forms linking to a file called process.php. Basically i need to know what code to put in the php file in order for the forms to save whatever is entered in them to a txt file on my server or computer. Or any other easier way to do the same thing, save the content of two forms on my site. Hope i posted this in the right forum subject. Thanks very much for anyone that helps. Similar TutorialsI have a web portal which is scripted using client side scripting language i.e HTML. I want to create a login page in .php and want the other pages to be in .hmtl. Can i do so? I want to do this because i want the login password to be stored in a database. Also I want the password to get encrypted (by either MD5 javascript or OpenSSL ) when user enters it inside the login form. I cannot create the entire portal in php because my portal makes use of C code. And php doesn't have an interface with C language. Can a user get directed to a .html page after a secure login from login.php page ? My main aim is to secure the access to my web portal using a password. I tried to authenticate the login using javascript where the password was stored in an array. But i feel any one having moderate knowledge can easily break that password. Any help would be greatly appreciated!! Here's a question for all you great php programmers. What I want to do is use a variable username as the name of a select input of a form. I.E echo"<select name='$user'>"; Of course this code doesn't work though I feel sure that there must be a way to do this. Anyone know it? I've been poking around online for about a day now trying to find a good way to do the following: I have an "order" I'm reading in from a MySQL database (not completely relevant, but just fyi). And, for this order there are a number of "parts" (automotive parts) that have been ordered. For each part there is data pertaining to the quantity of parts that have been ordered and the number of parts that have been allocated (based on our inventory) and then a third column that has the number of parts still in that order that are still to be allocated at a future date. Basically, I'm displaying this data in a form with each row having a checkbox to the far left. What I want to do is allow the user to check any number of check boxes. If a check box is checked the form should submit all of the input text boxes for that row (the user can update the quantities) that I talked about in the second paragraph for that "part" (each part is displayed in a row and has a checkbox). Unfortunately, most of the examples I found for checkboxes in a form submit a specific value (like a number of a letter). I need the form to submit the values that are in the textboxes. So basically, I'm thinking I need the page to update a PHP object whenever the value of a textbox is changed and then when the user clicks a button it will send the php object for each checked row through GET or POST. But, how would I get it to onchange update a PHP object (the PHP object would need to be a 2-D array where the first index allows you to select the part and the second index allows you to select which quantity you will change). I'm thinking I would need to call a script from the onchange like: onchange="somePHPfunction(partNumberIndex, whichQuantityI'mChanging, currentValueOfThatQuantity)" but of course that would require me to embed some php inside the onchange call since the partNumberIndex and whichQuantity are PHP variables.. Any ideas on how to do this sort of thing? Or any ideas on how to do this differently? I'm trying to avoid javascript because it would place a javascript constraint on the users. But, maybe there's no other way to do this sort of thing? Any help would be greatly appreciated! I found this site: http://www.wallpaperama.com/forums/how-to-save-html-output-code-from-php-script-t6898.html it demonstrates how to save html output code from php script. here is an example: http://ads4agents.com/date.php I cant get it to work on my site...where is the correct place ad these: ob_start(); $HtmlCode= ob_get_contents(); ob_end_flush(); How can I get this to work in my php? view_ad.php <html> <body> <center> <br/> <h1>Apartment Reference #: <?php echo $_POST["reference"]; ?><br /></h1> <br/> <?php echo $_POST["application"]; ?>, <?php echo $_POST["deposit"]; ?><br /> <?php echo $_POST["pets"]; ?><br /> <br/> <?php echo $_POST["community"]; ?><br /> <?php echo $_POST["interior"]; ?><br /> <?php echo $_POST["amenities"]; ?><br /> <br/> <?php echo $_POST["contact"]; ?><br /> <a href="<?php echo $_POST['website'] ?>"><?php echo $_POST['website'];?></a><br/> <br/> <br/> <br/> </body> </html> is it true that all the server side code runs before the client side code when accessing a webpage? if that is true, what about PHP code that is embedded inside HTML tags? wouldn't that result in an error a lot of times? 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 Hello all. I have a script that exports data from mysql to a csv file. Everything works great. However, I do not know how to save the csv file to the server. Does anyone have any ideas how I would do that? The script is below. Thanks for all help! Code: [Select] <?php $host = 'localhost'; $user = ''; $pass = ''; $db = ''; $table = ''; $file = 'export'; function escape_csv_value($value) { $value = str_replace('"', '""', $value); // First off escape all " and make them "" if(preg_match('/,/', $value) or preg_match("/n/", $value) or preg_match('/"/', $value)) { // Check if I have any commas or new lines return '"'.$value.'"'; // If I have new lines or commas escape them } else { return $value; // If no new lines or commas just return the value } } $link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error()); mysql_select_db($db) or die("Can not connect."); $result = mysql_query("SHOW COLUMNS FROM ".$table.""); $i = 0; if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $csv_output .= $row['Field'].", "; $i++; } } $csv_output .= "\n"; $values = mysql_query("SELECT * FROM ".$table.""); while ($rowr = mysql_fetch_row($values)) { for ($j=0;$j<$i;$j++) { $csv_output .= escape_csv_value($rowr[$j]).','; //$csv_output .= $rowr[$j].", "; } $csv_output .= "\n"; } $filename = $file."_".date("Y-m-d_H-i",time()); //header( "Content-Type: application/save-as" ); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m-d") . ".csv"); header( "Content-disposition: attachment; filename=".$filename.".csv"); //header( "Content-disposition: filename=".$filename.".csv"); print $csv_output; exit; ?> hello, since php is run server side, can i launch a program (.exe) on the server from a link? I'm trying to learn how to validate a form using the php server side method. Everything I search is very different and old. Anyone have knowledge of a good tutorial or source that I could use? None of my books have anything about it either! Thanks! I am doing server side validations using php and jquery.Its validating properly.But problem is the erros messages are displaying on the top of the page.I want to display side of field.All of the validations store in array.How to display errors to side of the field. I have a text box and a submit button. I want that when the submit button is pressed, the value on the text box will be checked if it matches the values that are on my server before proceeding, and if they don't match it should give an error report and stop. All I can make myself is the text box and the submit button, I have tried for hours to find a way to do the rest, but all I can find on the internet are vague explanations and information that a novice like me cannot use. It would be a shame to let me web site that I have worked hard on to go to waste because I cannot do this myself Thank you in advance I have a form which a user enters information like age, email, address. This information is emiled to the admin. I would like the information to also be saved to a textfile on the server when the same button is pressed Please help Thank you in advance, for your time and effort I have seen a couple of other threads relatively similar but I still find my problem unique so I hope you guys give me a chance.
What I want to do: use proxy to bypass same origin policy and to save these values (that changes and need to be checked by timer) into variables that can be modified.
A server contains data.asp which looks something like this and updates from time to time (although with a bit more data):
{ "Title":"Tile of song" ,"Artist":"The artist" ,"Album":"The album" ,"CDCover":"/covers/randomcover.jpg" }The method I have tried is like the one on http://qnimate.com/s...Policy_for_AJAX. In case you guys don't want to follow the link I've posted the data here as well. <script> function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","http://www.qnimate.com/ajaxdata.php",true); xmlhttp.send(); } </script> </head> <body> <button type="button" onclick="loadXMLDoc()">Request data</button> <div id="myDiv"></div>And the proxy file: <?php echo file_get_contents('http://www.qscutter.com/ajaxdata.txt'); ?>So what I want to do is store the data into variables that I can alter, not show it inside a div using innerHTML. Preferably check this ever so often for changes as well. Suggestions? I can add that I have the permission from the server owner to retrieve the information and to use it but no possibility to add script to their server, hence the proxy bypass attempt. Hi I am presently writing a code which does the following steps given a site 1) get some keywords (written a function for it) 2) search google for these keywords (I have used curl and getURL functions for these) 3) perform keyword search in the first page of googles results. Presently I have used curl and curl_multi_getcontent but when i run the code it consumes 100% of my server. My server will not respond in this case if someone else pings. I have been trying to do pcntl_fork, but could you let me know how to optimize this code by threading and forking. I am a newbe in PHP please let me know the structure of how to invoke multiple threads and process the same. If you have someother suggestions please let me know that too. Hello,
I want to grab some data using a script from this site.
But I am stuck right at the beginning. If you make a selection with the drop down boxes you get some output. For example you select:
Selecteer competitienaam: Najaarscompetitie 2014 Selecteer competitiegroep: Eredivisie dames Selecteer weergave: Programma (incl. uitslagen en stand) Optioneel poule filter: De Treffers R Selecteer poule(s): Eredivisie - Poule A I want to grab this output. When I look at the page source it is inside an iframe: <iframe src="http://www.nttb-competitie.nl/" width="100%" height="1200" scrolling="yes" frameborder="0" name="NTTB_Competitie"></iframe>I figured out: The script on the site first it gets url: http://www.nttb-competitie.nl/selectie.php?anr=0And after last selection it gets url: http://www.nttb-competitie.nl/web_programma.php?reset=0&pidString=1009267&sc=0&vastgesteldeAfdelingsnr=0&cnid=10085&cid=10704&view=programma&pf=1269&pid=1009267My problem is when I copy those URL's in a webbroser I get a page with only the words: Ongeldige aanroep!Which means "Invalid Call!" So my question is: How can I grab the data instead of this stupid message. Is it even possible or is it somehow protected? Please help! I hope I'm posting in the correct forum. If not, I'm super sorry! Anyways, I need help with a website I'm working on. We have been asked to redesign our "Apply Online" page. My supervisor has asked that I find the correct code to make an upload button that will allow users to upload their resumes to our server, and send a copy to the specific branch they indicate (we have 17 branches). Could any of you point me in the correct direction for this code? I've seen several sites for Uploads to servers, but I'm worried this isn't exactly what we are looking for. Hi all. I have a video upload page utilizing ffmpeg to convert to .flv format via ajax with progress bar. Currently I am having an issue where the user uploads the video however the same upload script also converts to .flv format (exec("ffmpeg -i etc..")) after the file is uploaded. This is working fine however if the user selects to move away from the page after the video is uploaded it is causing the users browser to lockup (and sometimes crash). How can I make the exec() command to convert the video format strictly run server side and allow the user to move away from the page even though the conversion is still processing? Thanks for any advise on how to handle this issue. Basically what I am trying to achieve is making sure any $page called originates from my server, but if no $page is defined, to include a default page I have set up. This is my code, and I cannot figure out what's wrong with it. Code: [Select] <?php $path = 'pages/'; $extension = '.txt'; if ( preg_match("#^[a-z0-9_]+$#i",$page) ){ $filename = $path.$page.$extension; include($filename); } if (!$page) include 'pages/main.txt'; ?> An example URL I am using is www.mywebsite.com/index.php?$page=pages/tester What am I doing wrong? |