Jump to content

korndevil666

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

korndevil666's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thanks, ill think ill just do that
  2. yes, the second option - authenticate . thanks,
  3. im trying to use a key to validate the client.php/server.php at the moment client.php uses a key that sends data along a form, code is <?php $key1 = rand(1, 10000); $encrypt_key = bin2hex($key1); ?> so encrypt_key is sent along with a form of other variables i need somehow to use the key created in client.php and validate it in server.php so only that key works, which then allows access to the script (displays form), but i cannot send unencrypted key to server. or if you can point me to any other simple way of sending encrypted data, much apprechiated!
  4. actually nevermind, it was just a typo on column(s) THANKS!
  5. It works - sort of. it doesnt seem to be generating the <td>, just the <tr> output for 5,5 is <table><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr></table>
  6. Hi, i have two files. client.php/server.php. Basically the client selects a drop down box of the number of rows and number of columns. This is then converted into 1 string and sent to the server. The server then splits the strings back again and then generates the table using the numbers from the strings. What i need help is, basically i've done everything except the loop for actually generating the table using the numbers; because i have no idea. ill post the code below. Its fairly straight forward since im just starting to use php and it isn't particulary good code, but i've commented everything anyway. If anyone could take a look and help me out, much apprechiated! Client.php <html> <head> </head> <body> <?php if(isset($_POST['submit'])) { $row = $_POST["rows"]; $column = $_POST["column"]; $com = ","; $str = ($row . $com . $column); do_it($str); } ?> <form action="<?=$_SERVER['PHP_SELF'];?>" method="post"> <label><strong>Table Generator</strong><br> <br> Rows <select name="rows" id="rows"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> </select> </label> <br> <label> Columns <select name="column" id="column"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> </select> </label> <p> <input type="submit" name="submit" value="Generate"> </form> <? function do_it($str) { // set some variables $host = "localhost"; $port = 10010; $ret; // create socket $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); // connect socket $ret = socket_connect($socket, $host, $port); $str = $str . "\n"; // socket write socket_write($socket, $str); $input = socket_read($socket,1024); $input = trim($input); echo $input; socket_close($socket); } ?> </body </html> Server.php <? // set some variables $host = "localhost"; $port = 10010; // timeout! set_time_limit(30); do{ // create socket $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); // bind socket to port $result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n"); // start listening for connections $result = socket_listen($socket, 3) or die("Could not set up socket listener\n"); // accept incoming connections // spawn another socket to handle communication $spawn = socket_accept($socket) or die("Could not accept incoming connection\n"); // read client input $input = socket_read($spawn, 1024); // clean up input string $input = trim($input); // set input back to $str $str = $input; //split the text using , to get rows and columns $pieces = explode(",", $str); //set row and column back to variables $rows = $pieces[0]; $column = $pieces[1]; // output the variables $output = ("$rows,$column"); // write back to socket socket_write($spawn, $output, strlen ($output)) or die("Could not write output\n"); // close sockets socket_close($spawn); socket_close($socket); }while ($input != “END”); ?> [attachment deleted by admin]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.