PHP - Client And Server Side Validation (passing Data From Server To Client)
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 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!! Hi All - I'm trying to see if the below is possible using PHP. is it possible for php to allow a user to check if a port is open/listening on a remote server/PC, from their local machine. I've seen scripts on the web that talk about opening cmd.exe - this won't work as not all of my users will be on windows. Also saw fsock.. but the remote server is not serving http page(s). Also saw telnet, but again, some of my users may not have that windows feature enabled. Desired workflow: 1. user enters the server hostname/IP and a port 2. my php webapp will emulate checking if that hostname and port is open from the local user's computer.
thanks! 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 want to do simple client side validation but I don't know Javascript. Can someone point me to an easy example on how to implement or post something here? I have to some how get data from my sql data to a clients sql db server. They suggested using xml which is great i can output the required fields as xml but how then do i push this so it goes into the clients sql db.. We cant just do a db insert this has been ruled out. Im happy using xml just have no idea how to push it at a particular host / sql db any ideas or suggestions would be really welcome.. I have a client and a server solution setup at the moment. We are currently creating an API that will be run on the clients end that will allow their clients to connect to them. On our end, we want to log the number of attempts are API is being used so that we may charge the clients appropriately. My question is this. How is the most efficient way of doing this? Do I call mysql_connect from the client and just shoot the insert log statements across the web. Should I create a php script on our end that looks for post/get input and takes the data and inserts it? What if the client can't connect to our server; should I cache the data and send it off all at once? Should I create a job that every hour shoots up x records API requests happened? Relatively confused at what angle I should be taking when approaching this. I want this to be scalable to a point where we can have thousands of requests an hour, and not horribly slow down apache/mysql running at either end (Specially if the server is talking with several clients). Hi, I need to make web site, which will get requests from users that log in and activate those scripts. But, the problem is that the server has to, when the script is activated, send request to another PC with the static IP address. Then, that PC should execute the script, send its results to server, and then the server will notice user who activated it (clicked on the link). So, the main problem is that server - client (static ip) communication, when the server is the first who sends request, not the client. Any instructions would be appreciated, thanks in advance. Hello; I know there is a way but I just can't get it out of my head. I have my code that i want to show to the user and then i have code i want to execute but not show anything to user. I no am not making my self clear which i am sorry for so ill give you an example. <? show_my_site(true); // Now i have code which will never output anything but the webbrowser will always wait for it to complete my_function_that_takes_time(true, 'Very Long'); ?> So what i want is some code to tell the browser thats it! You have everything. I cant use die; or exit; because i want to execute the code. Thank-you Paul I designed a web form that takes as input a file and that should upload that file on the server. The file is located on the client machine. The page containing the web form is handled by PHP script. I found out (reading 9483658954 forum topics so far) that there are 2 methods for getting a file uploaded. The first one is using FTP, and the second one using $_FILES variable. Unfortunately i have complains regarding both of the methods. Firstly, when attempting to upload the file using FTP it seems that rather the FTP server is calling "upload" a simple copy action (because the only successful thing i could do with FTP was to copy a file from location A to location B, both A and B being on the server) or I don't know to use FTP (which is probably the right answer). Then, when using $_FILES variable, I was forced to include ' enctype="multipart/form-data" ' in the form tag. After a long documentation I finally figured out that by including the enctype blah blah, the $_POST and $_FILES variables were NULL after the form was submitted.Still can't understand why! Are there any other methods for uploading a file from the client machine to the server? Can I get a competent script for this? Can someone please help me in setting up OAuth server and client implementation in PHP? Even after lots of googling I could only find very basic and raw examples which are very difficult to understand. Thanks in advance.
i have php at server side and c++ at client side.what i am trying to do is to constantly look for files on server in folder on server if there’s a file in folder then download it on client side and delete it from server folder This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=347977.0 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 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 Hi.., I use below method to export data to excel. header('Content-type: application/ms-excel'); header('Content-Disposition: attachment; filename=abc.xls'); if I run the script from the server. (http://localhost/export.php) it is work. (pop-up window if i want save or open the file) but if i run the script from the client (http://192.168.1.5/export.php) it is not work. (nothing happen) any idea how to solve this? Anyone know how I can print a file (specifically a PDF) that is stored on the server to the clients computer with a button? I don't want them to be able to view it, just print it. I've done some research and understand that there is no way to print directly without popping up the Windows Print dialog. And that is fine. I just want them to print this file, but not no where it is or be able to type in a URL to access it. Thanks Mike 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! Here's the code that deals with the client side:
<?php session_start(); if(!isset($_SESSION['Logged_in'])){ header("Location: /page.php?page=login"); } ?> <!DOCTYPE Html> <html> <head> <!--Connections made and head included--> <?php require_once("../INC/head.php"); ?> <?php require_once("../Scripts/DB/connect.php"); ?> <!--Asynchronously Return User Names--> <script> $(document).ready(function(){ function search(){ var textboxvalue = $('input[name=search]').val(); $.ajax( { type: "GET", url: 'search.php', data: {Search: textboxvalue}, success: function(result) { $("#results").html(result); } }); }; </script> </head> <body> <div id="header-wrapper"> <?php include_once("../INC/nav2.php"); ?> </div> <div id="content"> <h1 style="color: red; text-align: center;">Member Directory</h1> <form onsubmit="search()"> <label for="search">Search for User:</label> <input type="text" size="70px" id="search" name="search"> </form> <a href="index.php?do=">Show All Users</a>|<a href="index.php?do=ONLINE">Show All Online Users</a> <div id="results"> <!--Results will be returned HERE!--> </div>search.php <?php //testing if data is sent ok echo "<h1>Hello</h1><br>" . $_GET['search']; ?>This is the link I get after sending foo. http://www.family-li...php?&search=foo Is that mean it was sent, but I'm not processing it correctly? I'm new to the whole AJAX thing. Having some issues, hopefully you guys can identify a solution for me. There are 7 Servers involved in this situation - Each with its own website. Server 1 houses a page with content that is shared by the other 6 servers. I need to change an image (logo) at the top of Server 1 page based upon which server they originally came from. For example they are traveling from server 4, when they arrive at server 1 they see server 1 content however the image at the top will corrospond with correct brand in this example server 4's logo. Cookies have not been a reliable solution considering they are usually disabled. Please Help Guys, Any feedback is Fantastic! I'm in the habit of verifying input client side. For example, there is a field to enter a number, and I ensure that it is within a particular range using Javascript. My backend PHP code does not do such checking... Is this bad? Should I be doing checking using my backend code and send a response back to the client to display a message? Admittedly, I avoid it, since it's a little extra work -- well more extra than just javascripts, IF-THEN-ALERT type statement. |