Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Junior Member
    Join Date
    May 2011
    Location
    Kerala, India
    Posts
    11
    Member #
    27872
    hi,
    I am designing a website in HTML and PHP.The problem is that i've got a form which i need to validate using php. I have the form in a page which has 'action' attribute to the php page where validation is done and the result is send back to the previous page..

    its like this...

    My form page: newposting.php
    .
    .
    .
    <form name="entry" method="POST" action="posting_exec.php" style="width:300px; border-radius:5px; background-color:#CCCCCC;">
    <table style="background-color:#CCCCCC; border-radius:5px;" align="center">
    <tr>
    <td>Institution</td>
    <td><input type="text" name="inst" value="<?php if($_POST['inst']) echo $_POST['inst']; ?>" onfocus="clearForm()" /></td>
    </tr>
    <tr>
    <td>Place</td>
    <td><input type="text" name="pl" value="<?php if($_POST['pl']) echo $_POST['pl']; ?>" onfocus="clearForm1()"/></td>
    </tr>
    <tr>
    <td>District</td>
    <td><input type="text" name="dis" value="<?php if($_POST['dis']) echo $_POST['dis']; ?>" onfocus="clearForm2()"/></td>
    </tr>
    <tr>
    <td>Last date of Joining</td>
    <td><input type="text" name="lj" value="<?php if($_POST['lj']) echo $_POST['lj']; ?>" onfocus="clearForm3()"/></td>
    </tr>
    <tr>
    <td align="center" colspan="2"><input type="button" name="submit" value="Submit" /></td>
    </tr>
    </table>

    </form>
    .
    .
    .
    and my validation page: posting_exec.php


    <?php
    session_start();
    $errflag = false;

    $link = mysql_connect("localhost","root","");
    if(!$link) {
    die('Failed to connect to server: ' . mysql_error());
    }
    $db = mysql_select_db('PSC');
    if(!$db)
    {
    die("Unable to select database");
    }
    $errmsg_arr = array();
    function clean($str) // function to clean the strings..
    {
    $str = trim($str);
    if(get_magic_quotes_gpc())
    {
    $str = stripslashes($str);
    }
    return mysql_real_escape_string($str);
    }
    $ins=clean($_POST['inst']);
    $pl=clean($_POST['pl']);
    $dis=clean($_POST['dis']);
    $lj=clean($_POST['lj']);

    if($ins == '')
    {
    $errmsg_arr[] = 'Institution: Not filled';
    $errflag = true;
    }
    if(is_numeric($ins))
    {
    $errmsg_arr[]= 'Not a valid institution';
    $errflag=true;
    }
    if($pl == '')
    {
    $errmsg_arr[] = 'Place: Not filled';
    $errflag = true;
    }
    if(is_numeric($pl))
    {
    $errmsg_arr[]= 'Not a valid place';
    }
    if($dis == '')
    {
    $errmsg_arr[] = 'District: Not filled';
    $errflag = true;
    }
    if(is_numeric($dis))
    {
    $errmsg_arr[] = 'Not a valid district';
    $errflag = true;
    }
    if($lj == '')
    {
    $errmsg_arr[] = 'Last date of joining: Not filled';
    $errflag = true;
    }
    if(checkdate($lj))
    {
    $errmsg_arr[] = 'Invalid date';
    $errflag = true;
    }
    if($errflag)
    {
    $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
    session_write_close();
    header('Location: newposting.php');
    // exit();
    }
    else
    {
    $nu=$_SESSION['nou'];
    $qry = "INSERT INTO cand_det (insti,place,dist,last_doj) VALUES('$ins','$pl','$dis','$lj') where reg_no=$nu";
    $result = mysql_query($qry);
    if($result)
    {
    $val=1;
    $_SESSION['xy']=1;
    header('Location: newposting.php');
    // exit();
    }
    else
    {
    die("Query failed");
    }
    }
    ?>

    the validation is not happening and the 'action' attribute in the form page is not working....


    pls help...

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:22 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com