Jump to content

baxt01

Members
  • Content count

    20
  • Joined

  • Last visited

Community Reputation

0 Neutral

About baxt01

  • Rank
    Newbie
  • Birthday 07/03/1980

Contact Methods

  • MSN
    baxt01@hotmail.com
  • Skype
    baxt01@hotmail.com

Profile Information

  • Location
    UK

Previous Fields

  • Languages
    english
  1. how to sort() my data output from my DB SELECT

    spot on I was trying to do it after the SELECT statement using PHP lol
  2. Hi I have been working on building a custom post a result set to a database which thankfully I have now managed with some help, now I am working on the other end of this project the displaying the saved data back to users, From the start of this I have an online tournament hosting group that go to my form and post a list of player names with points earned per tournament. Once the form is submitted it's sent to my form_processing.php where the results are exploded and split into 2 arrays "$player_name, $points" Then on the INSERT I have an INSERT $sql = "INSERT into `bg_points` (`player_name`, `points`) values (?, ?) on duplicate key update points = points + ?"; to of course update current player points if the exist or add new records if not. Then finally saved into my DB table, now I am working on building the page to display these points back to the players so they can track their earned points and standings each month. which is easy enough I just call an MySQL SELECT * FROM statement on the DB table that's done, Now I need to sort these results in lowest to highest order by points so if player1 has 120 points player2 has 50 points player3 has 75 points player4 has 5 points then I need to be displaying these back as player4 player2 player3 player1 I have had a look online for some possible examples to help guide me into this and I either get HTTP 500 or just no effect at all. here is the very basic code I have put together so far which I can and will update and add into my site framework once I have it in order and working... <HTML> <head></head> <body bgcolor="#0000FF"> <?PHP $servername = "localhost"; $username = "***********"; $password = "*******"; $dbname = "***********"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //output the saved data $sql = "SELECT * FROM `bg_points` "; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "id: " . $row["id"]. " $nbsp $nbsp Playerv Name: " . $row["player_name"]. " $nbsp $nbsp Points: " . $row["points"]. "<br>"; } } else { echo "0 results"; } $conn->close(); ?> </body> </html> thanks for any help or ideas in advanced
  3. <?php error_reporting(E_ALL); ini_set("display_errors",1); include_once 'db_connect.php'; include_once 'functions.php'; sec_session_start(); // Our custom secure way of starting a PHP session. if (isset($_POST['email'], $_POST['p'])) { $email = $_POST['email']; $password = $_POST['p']; // The hashed password. if (login($email, $password, $mysqli) == true) { // Login success header('Location: ../protected_page.php'); } else { // Login failed header('Location: ../index.php?error=1'); } } else { // The correct POST variables were not sent to this page. echo 'Invalid Request'; } <?php error_reporting(E_ALL); ini_set("display_errors",1); include_once 'includes/db_connect.php'; include_once 'includes/functions.php'; sec_session_start(); if (login_check($mysqli) == true) { $logged = 'in'; } else { $logged = 'out'; } ?> <!DOCTYPE html> <html> <head> <title>Secure Login: Log In</title> <link rel="stylesheet" href="styles/main.css" /> <script type="text/JavaScript" src="js/sha512.js"></script> <script type="text/JavaScript" src="js/forms.js"></script> </head> <body> <?php if (isset($_GET['error'])) { echo '<p class="error">Error Logging In!</p>'; } ?> <form action="includes/process_logins.php" method="post" name="login_form"> Email: <input type="text" name="email" /> Password: <input type="password" name="password" id="password"/> <input type="button" value="Login" onclick="formhash(this.form, this.form.password);" /> </form> <?php if (login_check($mysqli) == true) { echo '<p>Currently logged ' . $logged . ' as ' . htmlentities($_SESSION['username']) . '.</p>'; echo '<p>Do you want to change user? <a href="includes/logout.php">Log out</a>.</p>'; } else { echo '<p>Currently logged ' . $logged . '.</p>'; echo "<p>If you don't have a login, please <a href='register.php'>register</a></p>"; } ?> </body> </html> hi I have been trying to setup a secure login system with some help from wikihow I have almost got everything working so far before I start adding some more features and css and so on I have my index page with the login or register for on when a user enters the email and password correctly the form action sends this to a "process_logins.php" page to verify the data and then redirect to the protected_page.php whats happening is when you hit login you get a HTTP500 error, I will post my codes from my index.php process_logins.php here:
  4. yes that's exactly it I had not noticed it before but INT is the default field setting in phpmyadmin left myself feel a little silly on this one but hey hoe its all working I can now go on to look at the next step in this project thanks very much I see you said the html is not right yes I know I leaves plenty to be worked on I just threw the basics codes in to make the pages display what I wanted I have to actually merge 2 pages now into a final result its a kind of point keeping sys I'm making so I want to add the form input field onto the same page as my out put narea and I want to change my output are to be displayed into a asocs array as to put it into a table then I can add another row into this html table to place a check box wich will have an ID of "win" once checked it will do a ++1 on the scoe field in the MySQL table and of course add some styling and tidy up the HTML coding in doing this
  5. <?php 2.error_reporting(E_ALL); 3.ini_set("display_errors",1); 4. 5. if (isset($_POST['submit'] ) ) { 6. $host_name = "localhost"; 7. $database = "DB name"; 8. $user_name = "user name"; 9. $password = "my p/w"; 10. 11. $db = mysqli_connect( $host_name, $user_name, $password, $database ); 12. 13. if (!$db) 14. { 15. die("ERROR please try reloading or email mike@mnvb.co.uk: " . mysql_error()); 16. } 17. 18. // example of inserting data into that table: 19. $sql = "INSERT INTO minis(name, score) " 20. . " VALUES( ?, ? )"; 21. 22. $stmt = $db->prepare( $sql ); 23. if (!$stmt) 24. { 25. die("Failed to prepare statement: " . $sql); 26. } 27. 28. // Get Values 29. $name=$_POST['name']; 30. $score="0"; 31. 32. $stmt->bind_param("ss", $name, $score); 33. 34. if ( ! $stmt->execute() ) 35. { 36. die("Execution of bound statement failed: " . $stmt->error); 37. } 38. 39. echo "Inserted {$stmt->affected_rows} correctly.<hr/>"; 40. 41. $db->close(); 42. } 43.?> 44.<!doctype html> 45.<html> 46. <head> 47. <meta charset="utf-8"> 48. <title>Music Cafe Minis</title> 49. </head> 50. 51. <body> 52. <div align="left"> 53. <form name="minis" action="" method="post"> 54. <table width="274" border="0" align="center" cellpadding="2" cellspacing="0"> 55. <tr> 56. <td width="95"><div align="right">Name:</div></td> 57. <td width="171"><input type="text" name="name" /></td> 58. </tr> 59. 60. <tr> 61. <input type="hidden" name="score" value="0"> 62. </tr> 63. 64. <tr> 65. <td><div align="right"></div></td> 66. <td><input name="submit" type="submit" value="Submit" /></td> 67. </tr> 68. </table> 69. </form> 70. 71. 72. 73. </body> 74.</html> hi I have had lots of issues around inserting form data into a MySQL table and extracting it but now I have mostly overcome those issues, I can now finally say my out put page works so thanks to anyone who helped with that, I can also say y form almost works, so my current issue is: I have built a very simple form to send data to a table in MySQL I have got error reporting turn on, ( I get no errors) once the form is submitted I see my pre set message that my record was added successfully, so I look on my output page and have even check my table through phpmyadmin to make sure a record has been created which yes that is correct a record is created however the form data is not inserted instead of sending my form data to MySQL its setting the value which should be a name to 0 please take a look over this coding I'm certain you can see for your self what is supposed to be happening and I hope you can debug it to tell me why it is not happening:
  6. PHP5 file upload file types

    /* index.php */ <html> <head> <title>Puddins's Page</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body background ="/puddin/files/BG_image.jpg"> <?PHP // open this directory $myDirectory = opendir("./files"); // get each entry while($entryName = readdir($myDirectory)) { $dirArray[] = $entryName; } // close directory closedir($myDirectory); // count elements in array $indexCount = count($dirArray); Print ("$indexCount files<br>\n"); // sort 'em sort($dirArray); // print 'em print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks>\n"); print("<TR><TH>Filename</TH></TR>\n"); // loop through the array of files and print them all for($index=0; $index < $indexCount; $index++) { if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files print("<TR><TD><a href=\"/puddin/files/$dirArray[$index]\" >$dirArray[$index]</a></td>"); print("</TR>\n"); } } print("</TABLE>\n"); ?> <!DOCTYPE html> <html> <body> <form action="./upload.php" method="post" enctype="multipart/form-data"> <p> <label for="file">Select a file:</label> <input type="file" name="userfile" id="file"> <br /> <button>Upload File</button> <p> </form> </body> </html> /* upload.php file */ <?php // Configuration - Your Options $allowed_filetypes = array('.jpg','.gif','.bmp','.png','.zip'); // These will be the types of file that will pass the validation. $max_filesize = 524288; // Maximum filesize in BYTES (currently 0.5MB). $upload_path = './files/'; // The place the files will be uploaded to (currently a 'files' directory). $filename = $_FILES['userfile']['name']; // Get the name of the file (including file extension). $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename. // Check if the filetype is allowed, if not DIE and inform the user. if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); // Now check the filesize, if it is too large then DIE and inform the user. if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize) die('The file you attempted to upload is too large.'); // Check if we can upload to the specified path, if not DIE and inform the user. if(!is_writable($upload_path)) die('You cannot upload to the specified directory, please CHMOD it to 777.'); // Upload the file to your specified path. if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)) echo 'Your file upload was successful, Go Back to last page to see files <a href="/puddin/index.php" title="Back To Your Files">here</a>'; // It worked. else echo 'There was an error during the file upload. Please try again.'; // It failed . ?> thanks for that I managed to get that code fixed by simply re writing the whole thing in a different style here is what I did next: however this new code has given me an issue I never would have seen coming once I setup my index.html page to work with the upload.php file from above my file counter seems to inherit 2 files from no where, in short even when my ./files directory is empty it is showing 2 files in the count there for it always shows 2 more files than are there anyone got any clues ok this text area works in an odd way at the very top is my index.php file followed by my upload.php
  7. PHP5 file upload file types

    <?php $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); // Check if image file is a actual image or fake image if(isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } ?> I have been working through the w3school tutorial on file upload but the codes are set to only use image file how do I change the file type that can be uploaded? above is the section of code were the file is checked and uploaded: I think its line 8 that controls the file type but I also think I am guessing
  8. PHP validation of a form not working!

    ok with a busy weekend with the kids I have now had the chance to sit and work out what was wrong in my coding and it is working again ( well kind of ) my page now loads again the form is there showing signs of validation presence on submit although the validation is showing up it is still posting data to my DB even if the content is not valid the odes say if field * is empty give error message but I can not work out how to make the code end or stop when there is an error I was wondering would something like: if ( ! $fname->valid() ) { die("field First Name incorret: " . $fname->error); } obviously some changes but in principal would that type of code on the end of each field test in my form work?
  9. PHP validation of a form not working!

    Ok i think i just seen some errors with how i have laid my codes out meaning it will not work as i have changed the variable names while the code validates so the stm call is now invalid also the section where i call the post values in the db conect code is still trying to call the orignal post values not the validated version so it becomes pointless * sigh * i will look when i get home from work i cant edit code from the iphone lol
  10. PHP validation of a form not working!

    HAHAHAHA that is just too funny! after my last comment to you as I said it should have been a easy fix problem well maybe for anyone else in the world perhaps............ I went to my codes figured I do not need to make a back up seen as I am not changing my codes im just re arranging them so I did it live I went onto my server and used copy and paste to re organise the codes so that my DB connect was at the end and my form was at the start leaving the validation codes in the middle sounds ok so far so I saved the work and loaded the page and well im now getting HTTP 500 internal server error im really not sure what exactly happened but it seems the server does not agree with the order of my codes............ so feel free to join me in starting over here is what I have that's giving me my HTTP 500 error: <html> <head> <meta charset="utf-8"> <title>Registration Form</title><style>.error {color: #FF0000;}</style> </head> <body> <form name="reg" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post"> <table width="274" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <td width="95"><div align="right">First Name:</div></td> <td width="171"><input type="text" name="fname" /> <span class="error">* <?php echo $fnameErr;?></span></td> </tr> <tr> <td><div align="right">Last Name:</div></td> <td><input type="text" name="lname" /> <span class="error">* <?php echo $lnameErr;?></span></td> </tr> <tr> <td><div align="right">Gender:</div></td> <td><input type="text" name="mname" /> <span class="error">* <?php echo $mnameErr;?></span></td> </tr> <tr> <td><div align="right">Address:</div></td> <td><input type="text" name="address" /> <span class="error">* <?php echo $addressErr;?></span></td> </tr> <tr> <td><div align="right">Contact No.:</div></td> <td><input type="text" name="contact" /> <span class="error">* <?php echo $contactErr;?></span></td> </tr> <tr> <td><div align="right">Picture:</div></td> <td><input type="text" name="pic" /> <span class="error">* <?php echo $picErr;?></span></td> </tr> <tr> <td><div align="right">Username:</div></td> <td><input type="text" name="username" /> <span class="error">* <?php echo $usernameErr;?></span></td> </tr> <tr> <td><div align="right">Password:</div></td> <td><input type="text" name="password" /> <span class="error">* <?php echo $passwordErr;?></span></td> </tr> <tr> <td><div align="right"></div></td> <td><input name="submit" type="submit" value="Submit" /></td> </tr> </table> </form> </body> </html> <?php // define variables and set to empty values$fnameErr = $lnameErr = $mnameErr = $addressErr = $contactErr = $picErr = $usernameErr = $passwordErr = "";$fname = $lname = $mname = $address = $contact = $pic = $username = $password = "";if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["fname"])) { $fnameErr = "First Name is required"; } else { $fname = test_input($_POST["fname"]); // check if first name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$fname)) { $fnameErr = "Only letters and white space allowed"; } } if (empty($_POST["lname"])) { $lnameErr = "Last Name is required"; } else { $lname = test_input($_POST["lname"]); // check if last name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$lname)) { $lnameErr = "Only letters and white space allowed"; } } if (empty($_POST["mname"])) { $mnameErr = "Gender is required"; } else { $mname = test_input($_POST["mname"]); // check if last name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$mname)) { $mnameErr = "Only letters and white space allowed"; } } if (empty($_POST["address"])) { $addressErr = "Address is required"; } else { $address = test_input($_POST["address"]); // check if last name only contains letters and whitespace if (!preg_match("/^[a-zA-Z0-9 ]*$/",$address)) { $addressErr = "Only letters numbers and white space allowed"; } } if (empty($_POST["contact"])) { $contactErr = "Contact Number is required"; } else { $contact = test_input($_POST["contact"]); // check if last name only contains letters and whitespace if (!preg_match("/^[0-9 ]*$/",$contact)) { $contactErr = "Only numbers and white space allowed"; } } if (empty($_POST["pic"])) { $picErr = "user Name is required"; } else { $pic = test_input($_POST["pic"]); // check if last name only contains letters and whitespace if (!preg_match("/^[a-zA-Z0-9 ]*$/",$pic)) { $picErr = "Only letters numbers and white space allowed"; } } if (empty($_POST["username"])) { $usernameErr = "user Name is required"; } else { $username = test_input($_POST["username"]); // check if last name only contains letters and whitespace if (!preg_match("/^[a-zA-Z0-9 ]*$/",$username)) { $usernameErr = "Only letters numbers and white space allowed"; } } if (empty($_POST["password"])) { $passwordErr = "Pasword is required"; } else { $passwrod = test_input($_POST["lname"]); // check if last name only contains letters and whitespace if (!preg_match("/^[a-zA-Z0-9]*$/",$password)) { $passwrodErr = "Only letters and numbers allowed"; } }}function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data;} if (isset($_POST['submit'] ) ) { $host_name = "localhost"; $database = "mnvbcou1_simple_login"; $user_name = "mnvbcou1_mike"; $password = "KaiSkye14"; $db = mysqli_connect( $host_name, $user_name, $password, $database ); if (!$db) { die("Failed to connect to MySQL: " . mysql_error()); } // example of inserting data into that table: $sql = "INSERT INTO simple_login(fname, lname, gender, address, contact, picture, username, password) " . " VALUES( ?, ?, ?, ?, ?, ?, ?, ? )"; $stmt = $db->prepare( $sql ); if (!$stmt) { die("Failed to prepare statement: " . $sql); } // Get Values $fname=$_POST['fname']; $lname=$_POST['lname']; $mname=$_POST['mname']; $address=$_POST['address']; $contact=$_POST['contact']; $pic=$_POST['pic']; $username=$_POST['username']; $password=$_POST['password']; $stmt->bind_param("ssssssss", $fname, $lname, $mname, $address, $contact, $pic, $username, $password); if ( ! $stmt->execute() ) { die("Execution of bound statement failed: " . $stmt->error); } echo "Inserted {$stmt->affected_rows} correctly.<hr/>"; $db->close();?> sorry to be a pain in the butt
  11. PHP validation of a form not working!

    yes this is one of them moments where im sat here feeling rather stupid, that moment where I have had a nights sleep and come back to it and read your comment looked down my codes thinking OMG what was I thinking coding is always set out by logical argument order of execution and I told the code to post form data to DB before I validate the $_POSt data that should be an easy fix then
  12. PHP validation of a form not working!

    right at the literal beginning 1. open code tag 2. and 3. error checking 4. - 15 if isset setting up connection and test 18 - 19 insert values MySQL comand
  13. PHP validation of a form not working!

    that was the missing line yep that was everything I needed right there LOL ok seriously though that just took me around 30 - 40 minutes of re - ordering spell checking AND finally that whole code does execute pretty perfectly! we have only 2 more things to ask of anyone who can help lol just looking at my TEST + Err system there is not any line there to tell the code to end before posting the incorrect data to my DB in my code it has a double IF check on the same field of the form first IF empty msg required field secondly check field content format preg match if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["fname"])) { $fnameErr = "First Name is required"; } else { $fname = test_input($_POST["fname"]); // check if first name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$fname)) { $fnameErr = "Only letters and white space allowed"; } } I was thinking would it word to add to this else / if statement 2 more else's or if's almost a repeat of what is there now but in replace of the fnameErr = msg change this to = EXIT type of thing?so that the php never posts the data it just stops or even goes back to the form if my thinking is on the right track I think I will try it but sometimes I try it break it and then am told I went all wrong way about it lol
  14. PHP validation of a form not working!

    i hear ya on the ssss I only added that error on here to show what was been thrown back but had already corrected as I fell into deep zzzZZZZZZ land tehe anyhow now is a fresh day bring yet another new set of errors and more mud to throw at my mental fan now the line issue is fixed with the array not having enough sss in i re mention the error researched on stack overflow above, from what I read this issue is way beyond my control on my server the PHP and MySQL versions and install are down to my system admin its not something I can change from my control panel I can view config data but not change so I will be sending a sharp email their way ok so for this moment lets move onwards and upwards with this code set of errors this next error been returned to me now I think I kind of know what its saying and maybe even why but how to fix im not as sure about so im hoping you guys / girls can confirm or correct my thoughts here: here is the error: Fatal error: Call to undefined function test_input() in /home/mnvbcou1/public_html/index1.php on line 69 61. // define variables and set to empty values62.$fnameErr = $lnameErr = $mnameErr = $addressErr = $contactErr = $usernameErr = $password = "";63.$fname = $lname = $mname = $address = $contact = $username = $password = "";64.65. if ($_SERVER["REQUEST_METHOD"] == "POST") {66. if (empty($_POST["fname"])) {67. $fnameErr = "First Name is required";68. } else {69. $fname = test_input($_POST["fname"]); ok so now if I re show the codes as a whole I can explain what I think is the issue, <?phpini_set('display_errors', 1); if (isset($_POST['submit'] ) ) { $host_name = "localhost"; $database = "mnvbcou1_simple_login"; $user_name = "mnvbcou1_mike"; $password = "KaiSkye14"; $db = mysqli_connect( $host_name, $user_name, $password, $database ); if (!$db) { die("Failed to connect to MySQL: " . mysql_error()); } // example of inserting data into that table: $sql = "INSERT INTO simple_login(fname, lname, gender, address, contact, picture, username, password) " . " VALUES( ?, ?, ?, ?, ?, ?, ?, ? )"; $stmt = $db->prepare( $sql ); if (!$stmt) { die("Failed to prepare statement: " . $sql); } // Get Values $fname=$_POST['fname']; $lname=$_POST['lname']; $mname=$_POST['mname']; $address=$_POST['address']; $contact=$_POST['contact']; $pic=$_POST['pic']; $username=$_POST['username']; $password=$_POST['password']; $stmt->bind_param("ssssssss", $fname, $lname, $mname, $address, $contact, $pic, $username, $password); if ( ! $stmt->execute() ) { die("Execution of bound statement failed: " . $stmt->error); } echo "Inserted {$stmt->affected_rows} correctly.<hr/>"; $db->close(); }?><!doctype html><html> <head> <meta charset="utf-8"> <title>Registration Form</title><style>.error {color: #FF0000;}</style> </head> <body> <?php// define variables and set to empty values$fnameErr = $lnameErr = $mnameErr = $addressErr = $contactErr = $usernameErr = $password = "";$fname = $lname = $mname = $address = $contact = $username = $password = "";if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["fname"])) { $fnameErr = "First Name is required"; } else { $fname = test_input($_POST["fname"]); // check if first name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$fname)) { $fnameErr = "Only letters and white space allowed"; } } if (empty($_POST["lname"])) { $lnameErr = "Last Name is required"; } else { $lname = test_input($_POST["lname"]); // check if last name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$lname)) { $lnameErr = "Only letters and white space allowed"; } } if (empty($_POST["mname"])) { $mnameErr = "Gender is required"; } else { $mname = test_input($_POST["mname"]); // check if last name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$mname)) { $mnameErr = "Only letters and white space allowed"; } } if (empty($_POST["address"])) { $addressErr = "Address is required"; } else { $address = test_input($_POST["address"]); // check if last name only contains letters and whitespace if (!preg_match("/^[a-zA-Z0-9 ]*$/",$address)) { $addressErr = "Only letters numbers and white space allowed"; } } if (empty($_POST["contact"])) { $contactErr = "Contact Number is required"; } else { $contact = test_input($_POST["contact"]); // check if last name only contains letters and whitespace if (!preg_match("/^[0-9 ]*$/",$contact)) { $contactErr = "Only numbers and white space allowed"; } } if (empty($_POST["username"])) { $usernameErr = "user Name is required"; } else { $username = test_input($_POST["username"]); // check if last name only contains letters and whitespace if (!preg_match("/^[a-zA-Z0-9 ]*$/",$username)) { $usernameErr = "Only letters numbers and white space allowed"; } } if (empty($_POST["password"])) { $passwordErr = "Pasword is required"; } else { $passwrod = test_input($_POST["lname"]); // check if last name only contains letters and whitespace if (!preg_match("/^[a-zA-Z0-9]*$/",$password)) { $passwrodErr = "Only letters and numbers allowed"; } }function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data;}}?> <form name="reg" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post"> <table width="274" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <td width="95"><div align="right">First Name:</div></td> <td width="171"><input type="text" name="fname" /></td> <span class="error">* <?php echo $fnameErr;?></span> </tr> <tr> <td><div align="right">Last Name:</div></td> <td><input type="text" name="lname" /></td> <span class="error">* <?php echo $lnameErr;?></span> </tr> <tr> <td><div align="right">Gender:</div></td> <td><input type="text" name="mname" /></td> <span class="error">* <?php echo $mnameErr;?></span> </tr> <tr> <td><div align="right">Address:</div></td> <td><input type="text" name="address" /></td> <span class="error">* <?php echo $addressErr;?></span> </tr> <tr> <td><div align="right">Contact No.:</div></td> <td><input type="text" name="contact" /></td> <span class="error">* <?php echo $contactErr;?></span> </tr> <tr> <td><div align="right">Picture:</div></td> <td><input type="text" name="pic" /></td> <span class="error">* <?php echo $picErr;?></span> </tr> <tr> <td><div align="right">Username:</div></td> <td><input type="text" name="username" /></td> <span class="error">* <?php echo $usernameErr;?></span> </tr> <tr> <td><div align="right">Password:</div></td> <td><input type="text" name="password" /></td> <span class="error">* <?php echo $paswordErr;?></span> </tr> <tr> <td><div align="right"></div></td> <td><input name="submit" type="submit" value="Submit" /></td> </tr> </table> </form> </body></html> I think this code is referring to the fact that the function call on line 69 is defined on line 136 maybe im just guessing with this but that's my best efforts on this
  15. PHP validation of a form not working!

    after I read your post I had to give myself a slap for not adding that error checking as I have been told about it before hey hoe its 2 am here lol ok so I added the error checking and corrected the silly typos and my form re appeared leaving these 2 error messages Warning: mysqli_connect(): Headers and client library minor version mismatch. Headers:50540 Library:100016 in /home/mnvbcou1/public_html/index1.php on line 9Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables in /home/mnvbcou1/public_html/index1.php on line 36Execution of bound statement failed: No data supplied for parameters in prepared statement ok so here is my code down to line 9 <?phpini_set('display_errors', 1); if (isset($_POST['submit'] ) ) { $host_name = "localhost"; $database = "mnvbcou1_simple_login"; $user_name = "mnvbcou1_mike"; $password = "KaiSkye14"; $db = mysqli_connect( $host_name, $user_name, $password, $database ); and here is 36 $stmt->bind_param("ssss", $fname, $lname, $mname, $address, $contact, $pic, $username, $password);
×