www.webdeveloper.com
Results 1 to 5 of 5

Thread: Form and script PHP

  1. #1
    Join Date
    Oct 2012
    Location
    Gujarat, India.
    Posts
    35

    Form and script PHP

    I have two PHP files, 1 for form of registration and other for adding users.

    When I am trying it, i am getting blank page when i press register button, please help.
    Thanks in advance!


    Registration_form.php

    HTML Code:
    <!DOCTYPE html>
    <html>
    <head>
    <script>
    function validateForm()
    {
    var x=document.forms["myForm"]["fname"].value;
    var y=document.forms["myForm"]["password"].value;
    if (x==null || x=="" || y==null || y=="" || y.length < 4) {
      if (x==null || x=="") {
      document.getElementById("FN").innerHTML = "First name must be filled out";
      }
    if (y==null || y=="") {
      document.getElementById("PW").innerHTML = "Password must be filled out. <br>";
    }
    if(y.length < 4 ) {
      document.getElementById("PW").innerHTML = "Password must be at least 4 characters long. <br>";
    }
      return false;
    } // If ends here
    }
    </script>
    </head>
      
    <body>
    <style>
    #FN, #PW {
    color: darkred;
    width: 200px;
    }
    
    </style>
    <form name="myForm" id="myForm" action="registration_script.php" onsubmit="return validateForm()" method="post">
    <table><tr><td>First name:*</td><td><input type="text" name="fname"></td><td><div id="FN"></div></td></tr>
    <tr><td>Password:* </td><td><input type="password" name="password"></td><td><div id="PW"></div></td></tr>
    <tr><td><input type="submit" value="Submit"></td></tr>
    </table>
    </form>
    <span style="color:red">Fields marked with asterisk ( * ) are required.</span>
    </body>
    
    </html>
    Registration_script.php

    PHP Code:
    <?php
    //=============Configuring Server and Database=======
    $db_host='host.abc.com';
    $db_user='user';
    $db_password 'pass';
    //=============Data Base Information=================
    $db_database='dbOfUsers';
    $con=mysql_connect($db_host,$db_user,$db_password);//or die('Server Information is not Correct'); //Establish Connection with Server
    mysql_select_db($db_database$con); //or die('Database Information is not correct');
    //===============End Server Configuration============
    //=============Starting Registration Script==========
    $userName=mysql_real_escape_string($_POST['fname']);
    $password=mysql_real_escape_string($_POST['password']);
    //=============To Encrypt Password===================
    $password=md5($password);
    //============New Variable of Password is Now with an Encrypted Value========
    if(isset($_POST['btnRegister'])) //===When I will Set the Button to 1 or Press Button to register
    {
    $query="insert into tbladmin(admin_usr_name,admin_pwd)values('$userName','$password')";
    $res=mysql_query($query);
    header('location:success_register.php');
    }
    *
    ?>
    Last edited by deepode; 10-17-2012 at 09:12 AM. Reason: old error resolved, new one!

  2. #2
    Join Date
    May 2003
    Posts
    599
    The asterisk there at the end of the script? Try at the beginning

    PHP Code:
    error_reporting(E_ALL);
    ini_set('display_errors','On'); 
    and at the end:

    PHP Code:
    header('Location: success_register.php');
    exit(); 
    We do precision guesswork

  3. #3
    Join Date
    Oct 2012
    Location
    Gujarat, India.
    Posts
    35

    Sorry, I solved it...

    sorry, i got what was problem, for new problem i have created new thread please check it.

  4. #4
    Join Date
    May 2003
    Posts
    599
    If the thread is resolved, please mark it that way...and document the solution out of courtesy for other users looking for help, so their browsing here is not useless.
    We do precision guesswork

  5. #5
    Join Date
    Oct 2012
    Location
    Gujarat, India.
    Posts
    35
    sorry but that still doesn't solves problem! I have changed all scripts.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles