Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 6 12345 ... LastLast
Results 1 to 10 of 55

Thread: Need PHP Code

  1. #1
    Join Date
    Aug 2006
    Posts
    282
    Tokens
    0

    Default Need PHP Code

    I need a PHP code so if someone typed in nothing in a field, it makes a JavaScript popup saying 'Please enter a message' or something.

    Correctable (Forum Moderator) - Thread moved to Coding. Please post in the correct sections.
    Last edited by lMattz; 09-08-2006 at 08:12 AM.

  2. #2
    Join Date
    Aug 2006
    Location
    United Kingdom
    Posts
    207
    Tokens
    0

    Default

    Try something like
    PHP Code:
    if($message == "") { echo "You haven't entered a message" 
    PHP Code:
    [LEFT]<?[/LEFT]
    [
    LEFT]$name $_GET['name'];[/LEFT]
    [
    LEFT]echo "Hi, your name is $name";[/LEFT]
    [
    LEFT]?>[/LEFT]
    [LEFT][/LEFT]

  3. #3
    Join Date
    Aug 2006
    Posts
    282
    Tokens
    0

    Default

    Thanks will try.

    Edit: Thats not a complete code, the echo tag looks uncompleted.
    Last edited by Drugs; 08-08-2006 at 08:49 PM.

  4. #4
    Join Date
    Aug 2006
    Location
    United Kingdom
    Posts
    207
    Tokens
    0

    Default

    You could try a javascript. In your form code put

    Code:
    <form name="shoutbox" onsubmit="return validate()">
    then in the HEAD tag of your page put

    Code:
    <SCRIPT>function validate() {
    with (document.form1) {
    var alertMessage = "The following field is empty:\n";
    if (name.value == "") {
    alertMessage += "\name" }
    if (message.value == "") {
    alertMessage += "\message" }
    if (alertMessage != "The following field is empty:\n") {
    alert(alertMessage);
    return (false);
    }
    return (true)
    }
    }</SCRIPT>
    Last edited by Fujitsu; 08-08-2006 at 08:54 PM.
    PHP Code:
    [LEFT]<?[/LEFT]
    [
    LEFT]$name $_GET['name'];[/LEFT]
    [
    LEFT]echo "Hi, your name is $name";[/LEFT]
    [
    LEFT]?>[/LEFT]
    [LEFT][/LEFT]

  5. #5
    Join Date
    Aug 2006
    Posts
    282
    Tokens
    0

    Default

    Sorry for double post ;P

    I used the following code;

    if ($name == "") {
    echo "Please enter a Name";
    }

    But when it comes up with "Please enter a name" it just redirects to the shoutbox and still submits the message.

  6. #6
    Join Date
    Feb 2006
    Location
    Coventry
    Posts
    2,096
    Tokens
    0

    Latest Awards:

    Default

    Just do:

    PHP Code:

    if(!$name) {

    echo 
    "

    <script language='javascript'>

    alert('Fill in your name');

    </script>

    "
    ;



  7. #7
    Join Date
    Aug 2006
    Location
    United Kingdom
    Posts
    207
    Tokens
    0

    Default

    Try

    PHP Code:
    <?php echo("Wouldn't Work, Code Removed"); ?>
    But looking at Sygon's code, that should work.
    Last edited by Fujitsu; 08-08-2006 at 09:01 PM.
    PHP Code:
    [LEFT]<?[/LEFT]
    [
    LEFT]$name $_GET['name'];[/LEFT]
    [
    LEFT]echo "Hi, your name is $name";[/LEFT]
    [
    LEFT]?>[/LEFT]
    [LEFT][/LEFT]

  8. #8
    Join Date
    Aug 2006
    Posts
    282
    Tokens
    0

    Default

    Sygon i used that but go to the site and type something in with no name..

    When you press ok on the alert, it just goes back to the shoutbox and types it in anyway.

    Fujitsu still typed it in anyway
    Last edited by Drugs; 08-08-2006 at 09:00 PM.

  9. #9
    Join Date
    Sep 2005
    Posts
    1,604
    Tokens
    0

    Latest Awards:

    Default

    Wrong section

    Correctable (Forum Moderator) - Please do not post pointlessly acting like a moderator.
    Last edited by lMattz; 09-08-2006 at 08:14 AM.

  10. #10
    Join Date
    Aug 2006
    Location
    United Kingdom
    Posts
    207
    Tokens
    0

    Default

    @ Chris

    So, does it really matter?

    Correctable (Forum Moderator) - Please stay on topic
    Last edited by lMattz; 09-08-2006 at 08:14 AM.
    PHP Code:
    [LEFT]<?[/LEFT]
    [
    LEFT]$name $_GET['name'];[/LEFT]
    [
    LEFT]echo "Hi, your name is $name";[/LEFT]
    [
    LEFT]?>[/LEFT]
    [LEFT][/LEFT]

Page 1 of 6 12345 ... LastLast

Posting Permissions

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