Folks,

I'm new to php so please excuse my ignorance.

I've setup a membership script but I would like to know where I can insert code to change font / background etc on the php page?

For example, how would I change the font for the 'could not establish connection' text below.

mysql_connect($server,$dbuser,$dbpass) or die ("Could not establish connection"); // make connection

    Just as you would in a static html page:

    <?php
    do or die('<font color="red" size="+1">Message</font>');
    ?>

      Or use Web 2.0, as a class to your stylesheet and use that (font tags were deprecated in HTML 4.01):

      .red{
        color: #ff0000;
      }
      
      mysql_connect($server,$dbuser,$dbpass) or die ("<span class='red'>Could not establish connection</span>"); // make connection
      

      or w/o a stylesheet

      mysql_connect($server,$dbuser,$dbpass) or die ("<span style='color:#ff0000;'>Could not establish connection</span>"); // make connection
      

        Yes...Agreed.

        Especially on a large scale it is much more efficient to use CSS. For example you could have a class called error in which you can set all kinds of attributes. On the PHP end all you have to do is enclose your error message inside <span class="error"> message </span> DIV or P tags work also.

        PHP simply creates an html page after it has been parsed at the server so anything you tell it to 'echo' will show up in the document.

          Thanks chaps, its much appreciated

            How and where can I add a 'go back' link in the code?

            mysql_connect($server,$dbuser,$dbpass) or die ("<font size=8.4pt face=verdana color=#666666>Could not establish connection</font>"); // make connection

            mysql_select_db($dbname); // select database

            // convert posted info to easy to use variables

            $user = $_REQUEST['username'];

            $pass = $_REQUEST['password'];

            // strip away any dangerous tags

            $user=strip_tags($user);

            $pass=strip_tags($pass);

            // remove spaces from variables

            $user=str_replace(" ","",$user);

            $pass=str_replace(" ","",$pass);

            // remove escaped spaces

            $user=str_replace("%20","",$user);

            $pass=str_replace("%20","",$pass);

            // add slashes to stop hacking

            $user=addslashes($user);

            $pass=addslashes($pass);

            // encrypt password into md5 (random 32 characters)

            $pass=md5($pass);

            // search database to check for user

            $request = "SELECT * FROM users WHERE password='".$pass."' AND username='".$user."'";

            // hand over the request

            $results = mysql_query($request);

            // if mysql returns any number of rows great than 0 then there is a succesful login

            if(mysql_num_rows($results))

            {

            // get users id

            $getid = "SELECT * FROM users WHERE username='".$user."' LIMIT 1";

            $getidexec = mysql_query($getid);

            while($r=mysql_fetch_array($getidexec)){

            $userid = $r[userid];

            }

            // set a cookie

            setcookie( "userid", "$userid", time()+3600, "/", "", 0 );

            echo "<font size=8.4pt face=verdana color=#666666>You are logged in.<br><br><a href=\"index.php\">click here to continue</font>";

            }

            else // only happens if not a succesful username and password match

            {

            // login failed so display error message and kill script

            die("<font size=8.4pt face=verdana color=#666666>Username and password combination are incorrect</font>");

            }

            ?>

              Write a Reply...