Results 1 to 4 of 4

Thread: PHP not working :(

Hybrid View

  1. #1
    Join Date
    Jun 2013

    PHP not working :(

    I'm new, to the forum and to PHP in general, and I would appreciate some help with this! It's probably a simple mistake! Here's the code, I need the 'loginForm' to show first, then once a name has been entered, it to view the rest of the body, here it is! (css and jquery works fine )

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <title>Chat - Customer Module</title>
    <link type="text/css" rel="stylesheet" href="style.css" />

    function loginForm(){
    <div id="loginform">
    <form action="index.php" method="post">
    <p>Please enter your name to continue:</p>
    <label for="name">Name:</label>
    <input type="text" name="name" id="name" />
    <input type="submit" name="enter" id="enter" value="Enter" />

    if($_POST['name'] != ""){
    $_SESSION['name'] = stripslashes(htmlspecialchars($_POST['name']));
    echo '<span class="error">Please type in a name</span>';



    <div id="wrapper">
    <div id="menu">
    <p class="welcome">Welcome, <b></b></p>
    <p class="logout"><a id="exit" href="#">Exit Chat</a></p>
    <div style="clear:both"></div>

    <div id="chatbox"></div>

    <form name="message" action="">
    <input name="usermsg" type="text" id="usermsg" size="63" />
    <input name="submitmsg" type="submit" id="submitmsg" value="Send" />
    <script type="text/javascript" src="jQuery.js"></script>
    <script type="text/javascript">
    // jQuery Document


  2. #2
    Join Date
    May 2013
    I think its problem with else statement missing firs check this statement. i hope you will be get solution.

  3. #3
    Join Date
    Mar 2012
    I haven't checked your code in detail, but I suspect there is a fundamental misunderstanding of how php works:

    a) Php does not run in the browser. You have to run it on a web server.

    b) Php will not output a web page to the client browser until it completes its processing on the server. It is not interactive like javascript.

  4. #4
    Join Date
    Aug 2012
    This might sound ridiculous but make sure your file extension is .php and not .html

    cause it seems to work fine for me when i loaded it to my environment.

    once i type my name in i get the chat box allowing me to post a message. the exit link is not destroying the session. you need to add


    or something to terminate the session allowing you to return to enter name when someone clicks exit.
    Last edited by Nicholas Diaz; 06-13-2013 at 04:43 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Recent Articles