SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict sleepingdanny's Avatar
    Join Date
    Oct 2002
    Location
    Israel
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Help => Script Not Working

    PHP Code:
    <?
    function emptyform(){
    if(
    $username=="" || $password==""){
    print 
    "You Have To Write Both Of Your Username And Password!<br><br>";}
    }
    ?>
    How do I write...
    <input type="submit" value="Login" onClick="emptyform()"> Or how ??

  2. #2
    webality...dunno what it means bcp_2005's Avatar
    Join Date
    Jun 2002
    Location
    Huntsville Alabama
    Posts
    394
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you trying to call the function emptyForm() when a user clicks the submit button? If so you'll need to write the function in Javascript.

    -Bryan

  3. #3
    Put your best practices away. The New Guy's Avatar
    Join Date
    Sep 2002
    Location
    Canada
    Posts
    2,087
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Ok the HTML should be something like:

    <input type="text" name="username">
    <input type="submit" name="submit">

    Then the php:
    PHP Code:
    <?
    if (isset($_POST['submit'])){
    emptyform();
    }
    else{
    }

    function 
    emptyform(){

    if(
    $_POST['username']=="" || $_POST['password']==""){

    print 
    "You Have To Write Both Of Your Username And Password!<br><br>";}

    }

    ?>
    "A nerd who gets contacts
    and a trendy hair cut is still a nerd"

    - Stephen Colbert on Apple Users

  4. #4
    SitePoint Addict sleepingdanny's Avatar
    Join Date
    Oct 2002
    Location
    Israel
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I'll try it

    By the way, yes I wont it to be called when the user clicks on the sumbit... bcp_2005

  5. #5
    No. Phil.Roberts's Avatar
    Join Date
    May 2001
    Location
    Nottingham, UK
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by sleepingdanny
    Thanks, I'll try it

    By the way, yes I wont it to be called when the user clicks on the sumbit... bcp_2005

    You cant do it that way with PHP, you have to either use Javascript or check the inputted values on another page.
    THE INSTRUCTIONS BELOW ARE OLD AND MAY BE INACCURATE.
    THIS INSTALL METHOD IS NOT RECOMMENDED, IT MAY RUN
    OVER YOUR DOG. <-- MediaWiki installation guide

  6. #6
    webality...dunno what it means bcp_2005's Avatar
    Join Date
    Jun 2002
    Location
    Huntsville Alabama
    Posts
    394
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, the only way to do that would be to write the function in Javascript. There's probably a post on the Javascript forum that'll tell you how do do it. If not try searching for it.

    -Bryan


Bookmarks

Posting Permissions

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