About Forms On Php HELP !

Discussion in 'PHP' started by realler, Jul 9, 2012.

  1. #1
    i wanna working on forms with php .

    but i cant achieve this.

    either i see empty a page or my codes.

    u think what must i do ?

    i didnt nothing except normal things.

    is odbc connect or mysql connect important for use forms on php ?

    pls help me

    Note:im new guy on php and eng :)
     
    Solved! View solution.
    realler, Jul 9, 2012 IP
  2. #2
    If you see your codes the problem is that your localhost server didn't start...

    You can install xampp to run it on your computer or you need a linux shared hosting to use php with mySQL.
     
    extraspecial, Jul 9, 2012 IP
  3. realler

    realler Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    my friend ı can use my localhost and ım usıng ApacheServer+EasyPHP

    ı can programming my applications but ı couldnt use forms

    ı guess ı must connect database wıth mysql for use form

    ı wıll sent u pm my phpmyadmin folder link

    thank u
     
    realler, Jul 9, 2012 IP
  4. realler

    realler Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ı cant sent ım sorry because of FAQ

    ı hope u can understand my problem
     
    realler, Jul 9, 2012 IP
  5. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #5
    If you see your code you don't have PHP running. Whether you "have PHP" or not, you don't have PHP - the parser itself - running. (Or you don't have PHP tags in your code, so the parser never runs on the code.)

    And no, you don't need SQL of any type running to create forms, unless you need data from the database to create the forms with. Forms are just plain old HTML.
     
    Rukbat, Jul 13, 2012 IP
  6. superlinksworld

    superlinksworld Member

    Messages:
    127
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    43
    #6
    Couple of things

    Make sure your running file on PHP server .

    For testing purpose you can download xampp which include every thing(php,ftp,mysql,phpmyadmin etc) and install it as webserver on windows its very easy just google for XAMPP Download.

    then

    build a form like

    
    <?php
    ?>
    <html>
    <head>
    <title> PHP Form </title>
    <style type="text/css">
    #stylized{
    
    background:#ebf4fb;
    margin:200px auto;
     
      width: 600px; 
    padding:0px;
    }
    #stylized br {
        clear:left; /* setting clear on inputs didn't work consistently, so brs added for degrade */
    }
    #stylized h1 {
    font-size:14px;
    font-weight:bold;
    margin-bottom:8px;
    }
    #stylized p{
    font-size:11px;
    color:#666666;
    margin-bottom:20px;
    border-bottom:solid 1px #b7ddf2;
    padding-bottom:10px;
    }
    #stylized label {
     display: block;  /* block float the labels to left column, set a width */
        float: left; 
        width: 200px; 
        padding: 0; 
        margin: 5px 0 0; /* set top margin same as form input - textarea etc. elements */
        text-align: right;
    } 
    #stylized fieldset {
      / * clear: both; note that this clear causes inputs to break to left in ie5.x mac, commented out */
      border-color: #000;
      border-width: 1px;
      border-style: solid;
      padding: 30px;        /* padding in fieldset support spotty in IE */
      margin: 0;
    }
    #stylized fieldset label:first-letter { /* use first-letter pseudo-class to underline accesskey, note that */
        text-decoration:underline;
    }
    #stylized fieldset legend {
        font-size:1.1em; /* bump up legend font size, not too large or it'll overwrite border on left */
                           /* be careful with padding, it'll shift the nice offset on top of border  */
    }
    #stylized .small{
    color:#666666;
    display: block;  /* block float the labels to left column, set a width */
        float: left; 
        padding: 0; 
        margin: 0 0 0 0; /* set top margin same as form input - textarea etc. elements */
        text-align: right;
    font-size:11px;
    font-weight:normal;
    
    width:190px;
    }
    #stylized .smalll {
    color:#666666;
    display: block;  /* block float the labels to left column, set a width */
        float: right; 
        width: 300px; 
        padding: 0; 
        margin: 0 0 0 0; /* set top margin same as form input - textarea etc. elements */
        text-align: left;
    font-size:11px;
    font-weight:normal;
    
    
    }
    #stylized input{
    /* display: inline; inline display must not be set or will hide submit buttons in IE 5x mac */
        width:auto;      /* set width of form elements to auto-size, otherwise watch for wrap on resize */
        margin:5px 0 0 10px; /* set margin on left of form elements rather than right of
                                  label aligns textarea better in IE */
    }
    #stylized textarea {
    /* display: inline; inline display must not be set or will hide submit buttons in IE 5x mac */
        width:auto;      /* set width of form elements to auto-size, otherwise watch for wrap on resize */
        margin:5px 0 0 10px; /* set margin on left of form elements rather than right of
                                  label aligns textarea better in IE */
    }
    #stylized select{
    float:left;
    font-size:12px;
    padding:4px 2px;
    border:solid 1px #aacfe4;
    margin:2px 0 20px 10px;
    }
    #stylized select{
    float:left;
    font-size:12px;
    padding:4px 2px;
    border:solid 1px #aacfe4;
    margin:2px 0 20px 10px;
    }
    #stylized img{
    float:left;
    font-size:12px;
    padding:4px 2px;
    margin:0px 0 20px 10px;
    }
    #stylized button{
    clear:both;
    margin-left:150px;
    width:125px;
    height:31px;
    background:#666666;
    text-align:center;
    line-height:31px;
    color:#FFFFFF;
    font-size:11px;
    font-weight:bold;
    }
    #stylized legend {
    padding: 0.2em 0.5em;
      border:1px solid green;
      color:green;
      font-size:90%;
      
    }
    </style>
    </head>
    <body>
    <?php
     if(!isset($_POST['submit'])){
    ?>
    <div id="stylized">
    <form id="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
             <fieldset>
            <legend>Account Login</legend>
            <label><span class="small"> User Name </span></label>    <input type="text" name="userName" value="" size="20"><br/>
            <label><span class="small">Enter Password  </span></label>       <input type="password" name="Password" size="20"> <br/>
            <button type="submit" name="submit"> Login</button> <br/>
            </fieldset>
    </form>
    <?php } else {
                    
                    $errors=array(); 
                    $username = mysql_real_escape_string($_POST['userName']);
                    $pass  = mysql_real_escape_string($_POST['Password']);
    if(empty($username) || empty($pass)) {
                        
                        $errors[]="All fields are mandatory";
                    }
    else {
    if(strlen($username)<4)
    {
    $errors[] = "Name must be atleast 4 characters";
    }
     if(strlen($pass)<4) {
                    
                    $errors[] = "Password Lenth Must Be Atleast 4 Characters Long";
                }
    }                     //displaying errors if any
    echo "<div>";
    if(!empty($errors))
    {
    foreach($errors as $error)
    {
    echo "{$error}<br/>";  
    }
    echo "</div>";
    }
    else
    {
    echo "<p>USERNAME = {$username}</p>";
    echo "<p>PASSWORD = {$pass}</p>";
    } 
    }
    ?>
    </div>
    </body>
    </html>
    
    Code (markup):
    Above form is self page submission

    and you can after success redirect user to other pages etc

    Save above file as PHP like form.php and put it in c:/xampp/htdocs/ folder and then in browser run it as http://localhost/form.php

    Hope its help

    if u have any question tell me

    Regards,

    D NAjmi
     
    superlinksworld, Jul 14, 2012 IP