#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    5
    Rep Power
    0
    I would like to get some help with checking if a form is empty.
    If the form is empty something like "sorry try again" should be printed.
    if it not empty then pass it on to searchprod.php3

    echo "<FORM METHOD=POST ACTION="searchprod.php3 ">n";
    echo "<INPUT TYPE=TEXT NAME=name VALUE="">n"; echo "
    <input type=SUBMIT name=SUBMIT value=search>

    regards
    Hazze
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    7
    Rep Power
    0
    hazze,

    if (!($name)) {
    header("Location: <A HREF="http://somewhere.com"0);" TARGET=_blank>http://somewhere.com"0);</A>
    exit;
    }
  4. #3
  5. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    But if you use javascript it is faster because you do not have to refresh the page.

    function valid(){
    if(document.cfone.Cname.value=="") {alert("empty field");return false;}
    }
    would be used with
    <form onsubmit="return cvalid()" name="cfone" action=.....etc>
    <input type=text name=Cname></form>

    or if you are using divs & netscape you can chuck in a bit of PHP snifing - cos this is the PHP section innit'.

    if(<?php if(!ereg( "MSIE", $HTTP_USER_AGENT)){ echo "document.NAMEofDIV.";}?>document.cfone.Cname.value=="") {alert("Please enter your name");return false;}

    (adds the path to the div for netscape as it has dodgy eyesight)

    Simon

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL

Similar Threads

  1. auto populating form
    By usrbin in forum PHP Development
    Replies: 1
    Last Post: February 11th, 2004, 02:10 PM
  2. check boxes in form
    By frazzle in forum PHP Development
    Replies: 1
    Last Post: February 7th, 2004, 02:13 PM
  3. empty form when user clicks back
    By mystang46 in forum ASP Programming
    Replies: 0
    Last Post: February 3rd, 2004, 05:23 PM
  4. HTTP Error 400: Bad Request, with basic form
    By crackwombat in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 07:40 PM
  5. form creation using php
    By emzyme in forum PHP Development
    Replies: 4
    Last Post: January 15th, 2004, 07:23 AM

IMN logo majestic logo threadwatch logo seochat tools logo