Jump to content

bigboss

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bigboss's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Form as requested <?php session_start(); if(!empty($_SESSION['logedin'])) { header("Location: controlpanel.php"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Register</title> <link href="css/joinery.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" /> <script type="text/javascript" src="js/prototype.js"></script> <script type="text/javascript" src="js/scriptaculous.js?load=effects"></script> <script type="text/javascript" src="js/lightbox.js"></script> </head> <body> <div class="header"> <div class="nav"> <a href="index.php">Home</a> | <a href="about.php">About</a> | <a href="products.php">Products</a> | <a href="contact.php">Contact</a> | <a href="location.php">Location</a> </div> <div class="login"> <a href="login.php">Login</a> / <a href="register.php">Register</a> </div> </div> <div class="background"> <div class="title">Register</div> <div class="content"> <em>All fields marked with a asteriks (*) are mandatory.</em> <br/> <br/> <form id="register" name="register" action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> <table width="400"> <tr> <td width="248">* Username:</td> <td width="200"><input name="username" type="text" maxlength="20"></td> </tr> <tr> <td> * Password:</td> <td><input name="password" type="password" maxlength="20"></td> </tr> <tr> <td> * Retype Password:</td> <td><input name="repassword" type="password" maxlength="20"></td> </tr> <tr> <td>* Email Address:</td> <td><input name="email" type="text" maxlength="127"></td> </tr> <tr> <td>* Retype Email Address:</td> <td><input name="reemail" type="text" maxlength="127"></td> </tr> <tr> <td>* First Name:</td> <td><input name="first_name" type="text" maxlength="50" /></td> </tr> <tr> <td>* Last Name:</td> <td><input name="last_name" type="text" maxlength="50"></td> </tr> <tr> <td>* Address Line 1:</td> <td><input name="address1" type="text" maxlength="50"></td> </tr> <tr> <td> Address Line 2:</td> <td><input name="address2" type="text" maxlength="50"></td> </tr> <tr> <td>* Town/City:</td> <td><input name="towncity" type="text" maxlength="50"></td> </tr> <tr> <td>* Postcode:</td> <td><input name="postcode" type="text" maxlength="20" value=""></td> </tr> <tr> <td> Telephone Number: <br /></td> <td><input name="telephone" type="text" maxlength="11"></td> </tr> </table> <br/> <em>Please enter the security code to the left.</em> <br/> <table width="400"> <tr> <td width="248"><img src="captcha.php"/></td> <td width="200"><input name="captcha" type="text" maxlength="6" /></td> </table> <br/> <input type="submit" value="Register" name="submit" /> </form> <?php if(isset($_POST['submit'])){ include 'config.php'; #Database connection info. include 'functions/functions.php'; #Functions page. /*Declare variables to hold values returned by validate() or hold errors.*/ $errors = array(); $username = validate('username','username',1); $password = validate('password','password',1); $email = validate('email','email',1); $first_name = validate('first_name','name',1); $last_name = validate('last_name','name',1); $address1 = validate('address1','address',1); $address2 = validate('address2','address',0); $towncity = validate('towncity','address',1); $postcode = validate('postcode','postcode',1); $telephone = validate('telephone','telephone',0); validate('captcha','captcha',1); /*mySQL for inserting or checking duplicate usernames or emails*/ $insert_query = "INSERT INTO users (username, password, email, first_name, last_name, address_line1, address_line2, town_city, postcode, telephone_number) VALUES('$username', '$password', '$email', '$first_name', '$last_name', '$address1', '$address2', '$towncity', '$postcode', '$telephone')"; if(sizeof($errors) > 0){ foreach ($errors as $index => $value){ echo "<br/>" . ($errors[$index]); } } else { $insert = mysql_query($insert_query); echo "<br/> Thanks for registering, Click <a href='login.php'/>Here</a> to login."; } } ?> </div> </div> <div class="footer"> <div class="copyright"> <div align="center">© 2007 J and S Joinery<br /> </div> </div> </div> </body> </html>
  2. Anyone? I can dump my code here, however there are a lot of functions diffrent pages called.
  3. Hi, I am trying to get a registration page to echo back values already added the form if one of the values is correct or a user forgets to add a value. I have tried using Value=" " but my variables are under my form code, so they can't be seen. I was just wondering if anyone had a way of returning values without using $_GET. Thanks.
  4. Hi, I've am working on a validation form and I've been trying to work out how to allow a ' and - for names. I have developed: <?php ereg("^[a-zA-Z ]$+", $string); ?> Which seems to work for names with spaces. I have tried to change the pattern to the code below to enable whitespace, the ' and a -. I have a pattern earlier in my code that seems to work for whitespace using this, and I even read in in a PHP book. I tried using a \ to add a literal character and the pattern still didn't work. <?php ereg("^[a-zA-Z' -]$+", $string); ?> I know I could use preg_match() and its faster, but I have already implemented ereg and I don't have the time to redo my code adding in preg_match. So can anyone see why the pattern isn't working.
  5. Hi, I've am working on a validation form and I've been trying to work out how to allow a ' and - for names. I have developed: <?php ereg("^[a-zA-Z ]$+", $string); ?> Which seems to work for names with spaces. I have tried to change the pattern to the code below to enable whitespace, the ' and a -. I have a pattern earlier in my code that seems to work for whitespace using this, and I even read in in a PHP book. I tried using a \ to add a literal character and the pattern still didn't work. <?php ereg("^[a-zA-Z' -]$+", $string); ?> I know I could use preg_match() and its faster, but I have already implemented ereg and I don't have the time to redo my code adding in preg_match. So can anyone see why the pattern isn't working.
  6. I would like to have a validation class, but the only OOP experience I've had in the past is Java. I'm not sure how PHP implements polymorphism, inheritance and encapsulation. This project is only for a small website and it is easier for me to code a small function that to learn OOP rules in PHP and then code a class.
  7. The include statement is above the call to the function. The whole structure of the register page is: <?php include 'config.php'; include 'functions/functions.php'; if(isset($_POST)){ } else { } ?> Also all errors are reporting.
  8. Hello, I am writing a validate function that works by passing the post value, the type of field and if the field is required. In my register page I call the function like: <?php validate($_POST['username'],'username',1); ?> The function is stored in a separate functions page in a functions directory. The code for the function is as folllows: <?php function validate($post_value,$field_type,$required){ if(isset($_POST[$post_value]) && (!empty($post_value)) || !$required){ }else{ } ?> I have included the functions page with <?php include 'functions/functions.php'; ?> But yet when I debug or run the code it seems as if my code can't see the function even though it enters the functions.php file. Have you guys got any ideas why this would be happening?
  9. I'm am looking to make a validation function. I have been thinking and would my general idea of having a system structured like this work? <?php #Register Page# include 'functions.php'; if(isset($_POST)){ validate($_POST['username'],"username",1); } <?php #Validate Function# function validate($field_name,$field_type,$required){ if(isset($_POST)){ switch ($field_type) case 'username': #block of code break; } } I still haven't figured out how I would make sure that the required worked, at first I thought about a || in the first if in the validate function, or how to return errors to the register page or MD5 passwords and inset the values into the database. Any ideas?
  10. I have wrote a series of if statements that work, however I have also wrote a foreach loop that does work for blank fields. I have also changed from using one register page to two pages, and using GET to pass the errors back to the register page. I know this seems stupid but this is the only way that I can use a header function. I have got confused on how I would use a loop to insert values into my database. Any ideas?
  11. I am designing a registration script for a small business, I was wondering what method I should use to validate the information. Should I use a foreach loop to loop thought the $_POST and check for blank fields and erroneous data, or should I use a series of if statements on their own or in a validate function? Any views are very much appreciated.
  12. You Sir, are a Gentleman and a Squire, It works!!! Does it now work by adding the value back onto the variable using the dot?
  13. Yeah I had noticed that's why I thanked Mark for helping me with my syntax. I did try what you suggested and move the header outside of the loop. As I suspected it doesn't fix the problem. I still only get one error returned, this is because it takes the last value in tr he array from the loop and not the whole value I wanted. Wanted output should be: u&p&rp&e&.. etc If I move the header all I get is. &te&. I'm most likely doing this the wrong way, or there is a way easier way out here to do the same thing.
  14. To reply to both posts. Thanks for all your help really appreciate it. I want users to be able to leave both of the fields blank so I am sure it is || instead of && because otherwise both of the fields will need to be blank for it to trigger. But Thanks for the help with the syntax. Thanks for the second reply, I did try that and it seemed to have the same effect as having the header within the foreach. I will try it though.
×
×
  • 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.