Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // If the form was submitted, scrub the input (server-side validation)
- // see below in the html for the client-side validation using jQuery
- $username = '';
- $password = '';
- $address = '';
- $email = '';
- $phone = '';
- $output = '';
- /* Set oracle user login and password info */
- $dbuser = "jccrawfo"; /* your deakin login */
- $dbpass = "password"; /* your deakin password */
- $db = "SSID";
- $connect = OCILogon($dbuser, $dbpass, $db);
- if($_POST) {
- // collect all input and trim to remove leading and trailing whitespaces
- $username = trim($_POST['username']);
- $password = trim($_POST['password']);
- $email = trim($_POST['email']);
- $phone = trim($_POST['phone']);
- $city = trim($_POST['company']);
- $address = trim($_POST['address']);
- $errors = array();
- // Validate the input
- if (strlen($username) == 0){
- array_push($errors, "Please enter your name");
- }
- if (strlen($password) < 6){
- array_push($errors, "Please enter a password. Passwords must contain at least 6 characters.");
- }
- if (strlen($address) == 0) {
- array_push($errors, "Please specify your address");
- }
- //if (!filter_var($email, FILTER_VALIDATE_EMAIL))
- //array_push($errors, "Please specify a valid email address");
- if (strlen($phone) == 0){
- array_push($errors, "Please enter a valid phone number");
- }
- // If no errors were found, proceed with storing the user input
- if (count($errors) == 0) {
- array_push($errors, "No errors were found. Thanks!");
- if (!$connect) {
- echo "An error occurred connecting to the database";
- exit;
- }
- // build INSERT query
- $query = "INSERT INTO account ( ID, username, password, email, Phone, address ) VALUES ( user_seq.nextval, '$username', '$password', '$email', '$phone', '$address' );";
- //echo "$query";
- /* check the sql statement for errors and if errors report them */
- $stmt = OCIParse($connect, $query);
- //echo "SQL: $query<br>";
- if(!$stmt) {
- echo "An error occurred in parsing the sql string.\n";
- exit;
- }
- oci_execute($stmt);
- }
- //Prepare errors for output
- $output = '';
- foreach($errors as $val) {
- $output .= "<p class='output'>$val</p>";
- }
- }
- ?>
- <!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>
- <script src="//code.jquery.com/jquery-1.9.1.js"></script>
- <script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
- <!-- jQuery Form Validation code -->
- <script>
- // When the browser is ready...
- $(function() {
- // Setup form validation on the #register-form element
- $("#register").validate({
- // Specify the validation rules
- rules: {
- name: "required",
- phone: "required",
- address: "required",
- email: {
- required: true,
- email: true
- },
- username: "required",
- password: {
- required: true,
- minlength: 6
- }
- },
- // Specify the validation error messages
- messages: {
- name: "Please enter your name",
- phone: "Please specify your phone number",
- address: "Please enter your address",
- email: "Please enter a valid email address",
- username: "Please enter a valid username",
- password: {
- required: "Please provide a password",
- minlength: "Your password must be at least 5 characters long"
- }
- },
- submitHandler: function(form) {
- form.submit();
- }
- });
- });
- </script>
- <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
- <title>Pet Shop</title>
- <link rel="stylesheet" type="text/css" href="style.css" />
- </head>
- <body>
- <div id="wrap">
- <div class="header">
- <div class="logo"><a href="index.html"><img src="images/logo.gif" alt="" title="" border="0" /></a></div>
- <div id="menu">
- <ul>
- <li><a href="index.html">home</a></li>
- <li><a href="about.html">about us</a></li>
- <li><a href="category.xml">category</a></li>
- <li><a href="specials.html">specials</a></li>
- <li><a href="details.html">details</a></li>
- <li><a href="myaccount.html">my accout</a></li>
- <li class="selected"><a href="register.html">register</a></li>
- <li><a href="contact.html">contact</a></li>
- </ul>
- </div>
- </div>
- <div class="center_content">
- <div class="left_content">
- <div class="title"><span class="title_icon"><img src="images/bullet1.gif" alt="" title="" /></span>Register</div>
- <div class="feat_prod_box_details">
- <p class="details">
- Register a new account to buy our products!
- <?php echo $output; ?>
- </p>
- <div class="contact_form">
- <div class="form_subtitle">create new account</div>
- <form action="register.php" id="register" method="post">
- <div class="form_row">
- <label class="contact"><strong>Username:</strong></label>
- <input type="text" name="username" class="contact_input" />
- </div>
- <div class="form_row">
- <label class="contact"><strong>Password:</strong></label>
- <input type="text" name="password" class="contact_input" />
- </div>
- <div class="form_row">
- <label class="contact"><strong>Email:</strong></label>
- <input type="text" name="email" class="contact_input" />
- </div>
- <div class="form_row">
- <label class="contact"><strong>Phone(with area code):</strong></label>
- <input type="text" name="phone" class="contact_input" />
- </div>
- <div class="form_row">
- <label class="contact"><strong>Address:</strong></label>
- <input type="text" name="address" class="contact_input" />
- </div>
- <div class="form_row">
- <label class="contact"><strong>City:</strong></label>
- <input type="text" name="address" class="contact_input" />
- </div>
- <div class="form_row">
- <div class="terms">
- <input type="checkbox" name="terms" />
- I agree to the <a href="#">terms & conditions</a> </div>
- </div>
- <div class="form_row">
- <input type="submit" class="register" value="register" />
- </div>
- </form>
- </div>
- </div>
- <div class="clear"></div>
- </div><!--end of left content-->
- <div class="right_content">
- <div class="languages_box">
- <span class="red">Languages:</span>
- <a href="#"><img src="images/au.gif" alt="" title="" border="0" height="12px" width="15px"/></a>
- <!-- commented out by Shang 10/07/2014
- <a href="#"><img src="images/gb.gif" alt="" title="" border="0" /></a>
- <a href="#"><img src="images/fr.gif" alt="" title="" border="0" /></a>
- <a href="#"><img src="images/de.gif" alt="" title="" border="0" /></a>
- -->
- </div>
- <div class="currency">
- <span class="red">Currency: </span>
- <!-- commented by shang 10/07/2014
- <a href="#">GBP</a>
- <a href="#">EUR</a> -->
- <a href="#" class="selected">AUD</a>
- </div>
- <div class="cart">
- <div class="title"><span class="title_icon"><img src="images/cart.gif" alt="" title="" /></span>My cart</div>
- <div class="home_cart_content">
- 3 x items | <span class="red">TOTAL: 100$</span>
- </div>
- <a href="cart.html" class="view_cart">view cart</a>
- </div>
- <div class="title"><span class="title_icon"><img src="images/bullet3.gif" alt="" title="" /></span>About Our Shop</div>
- <div class="about">
- <p>
- <img src="images/about.gif" alt="" title="" class="right" />
- Pet Shop is an Australian owned & operated pet store that stocks a range of pets and accessories in Geelong. Our online store sells a large selection of dogs, cats, birds and beetles. Make our Pet Shop your first choice for pets!
- </p>
- </div>
- <div class="right_box">
- <div class="title"><span class="title_icon"><img src="images/bullet4.gif" alt="" title="" /></span>Promotions</div>
- <div class="new_prod_box">
- <a href="details.html">product name</a>
- <div class="new_prod_bg">
- <span class="new_icon"><img src="images/promo_icon.gif" alt="" title="" /></span>
- <a href="details.html"><img src="images/thumb1.gif" alt="" title="" class="thumb" border="0" /></a>
- </div>
- </div>
- <div class="new_prod_box">
- <a href="details.html">product name</a>
- <div class="new_prod_bg">
- <span class="new_icon"><img src="images/promo_icon.gif" alt="" title="" /></span>
- <a href="details.html"><img src="images/thumb2.gif" alt="" title="" class="thumb" border="0" /></a>
- </div>
- </div>
- <div class="new_prod_box">
- <a href="details.html">product name</a>
- <div class="new_prod_bg">
- <span class="new_icon"><img src="images/promo_icon.gif" alt="" title="" /></span>
- <a href="details.html"><img src="images/thumb3.gif" alt="" title="" class="thumb" border="0" /></a>
- </div>
- </div>
- </div>
- <div class="right_box">
- <div class="title"><span class="title_icon"><img src="images/bullet5.gif" alt="" title="" /></span>Categories</div>
- <ul class="list">
- <li><a href="#">accesories</a></li>
- <li><a href="#">pets gifts</a></li>
- <li><a href="#">specials</a></li>
- <li><a href="#">hollidays gifts</a></li>
- <li><a href="#">accesories</a></li>
- <li><a href="#">pets gifts</a></li>
- <li><a href="#">specials</a></li>
- <li><a href="#">hollidays gifts</a></li>
- <li><a href="#">accesories</a></li>
- <li><a href="#">pets gifts</a></li>
- <li><a href="#">specials</a></li>
- </ul>
- <!-- commented out by Shang 10/07/2014
- <div class="title"><span class="title_icon"><img src="images/bullet6.gif" alt="" title="" /></span>Partners</div>
- <ul class="list">
- <li><a href="#">accesories</a></li>
- <li><a href="#">pets gifts</a></li>
- <li><a href="#">specials</a></li>
- <li><a href="#">hollidays gifts</a></li>
- <li><a href="#">accesories</a></li>
- <li><a href="#">pets gifts</a></li>
- <li><a href="#">specials</a></li>
- <li><a href="#">hollidays gifts</a></li>
- <li><a href="#">accesories</a></li>
- </ul>
- -->
- </div>
- </div><!--end of right content-->
- <div class="clear"></div>
- </div><!--end of center content-->
- <div class="footer">
- <div class="left_footer"><img src="images/footer_logo.gif" alt="" title="" /><br /> <a href="http://csscreme.com/freecsstemplates/" title="free css templates"><img src="images/csscreme.gif" alt="free css templates" border="0" /></a></div>
- <div class="right_footer">
- <a href="#">home</a>
- <a href="#">about us</a>
- <a href="#">services</a>
- <a href="#">privacy policy</a>
- <a href="#">contact us</a>
- </div>
- </div>
- <p>"©Deakin University, School of Information Technology. This web page has been developed as a student assignment for the unit SIT203: Web Programming. Therefore it is not part of the University's authorised web site. DO NOT USE THE INFORMATION CONTAINED ON THIS WEB PAGE IN ANY WAY."</p>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement