Robert Elsdon Posted May 4, 2008 Share Posted May 4, 2008 Hi guys im having trouble with my login page as people go to my webiste index.php is restricted only for member so it redirects to login.php but when it redirects to the login page, the login page dosent have a register buttong link so this is the code i want on the login page and i cant add this myself I want this code added to the login page: <?php { echo "<form action="?op=reg" method="POST">"; echo "<input type="submit\" value="Register">"; echo "</form>"; } ?> Login.php <?php session_start(); // dBase file include "dbConfig.php"; if ($_GET["op"] == "login") { if (!$_POST["username"] || !$_POST["password"]) { die("You need to provide a username and password."); } // Create query $q = "SELECT * FROM `dbUsers` " ."WHERE `username`='".$_POST["username"]."' " ."AND `password`=PASSWORD('".$_POST["password"]."') " ."LIMIT 1"; // Run query $r = mysql_query($q); if ( $obj = @mysql_fetch_object($r) ) { // Login good, create session variables $_SESSION["valid_id"] = $obj->id; $_SESSION["valid_user"] = $_POST["username"]; $_SESSION["valid_time"] = time(); // Redirect to member page Header("Location: index.php"); } else { // Login not successful die("Sorry, You have enterd a wrong Username or Paswword please try again and be more carefull with your spelling!"); } } else { //If all went right the Web form appears and users can log in echo "<form action=\"?op=login\" method=\"POST\">"; echo "Username: <input name=\"username\" size=\"15\"><br />"; echo "Password: <input type=\"password\" name=\"password\" size=\"8\"><br />"; echo "<input type=\"submit\" value=\"Login\">"; echo "</form>"; } ?> I hope you guys no what i am trying to say! please try and add the code to the login page! thanks to all of you who try and support me! Link to comment https://forums.phpfreaks.com/topic/104120-where-would-i-add-this-part-of-php-to-this-part-of-php/ Share on other sites More sharing options...
ady01 Posted May 4, 2008 Share Posted May 4, 2008 I Think I know what you mean, do you want the login page to include the php for registering ? Link to comment https://forums.phpfreaks.com/topic/104120-where-would-i-add-this-part-of-php-to-this-part-of-php/#findComment-533058 Share on other sites More sharing options...
Robert Elsdon Posted May 4, 2008 Author Share Posted May 4, 2008 Yes that is spot on! Do you no how to do that? Please do it for me and put the code in here please? Link to comment https://forums.phpfreaks.com/topic/104120-where-would-i-add-this-part-of-php-to-this-part-of-php/#findComment-533060 Share on other sites More sharing options...
ady01 Posted May 4, 2008 Share Posted May 4, 2008 One more Question just to make this easy to understand from this end... Are you putting your code into HTML ? E.g your web page looks like : www.example.com/index.html or www.example.com/login.php Link to comment https://forums.phpfreaks.com/topic/104120-where-would-i-add-this-part-of-php-to-this-part-of-php/#findComment-533062 Share on other sites More sharing options...
Robert Elsdon Posted May 4, 2008 Author Share Posted May 4, 2008 In PHP Link to comment https://forums.phpfreaks.com/topic/104120-where-would-i-add-this-part-of-php-to-this-part-of-php/#findComment-533066 Share on other sites More sharing options...
ady01 Posted May 4, 2008 Share Posted May 4, 2008 I see the problem here, you should consider having your login.php on included in a index.html page (looks better too with some design work) Then have a link for registration on this page : <a href=\"register.html Which will include your PHP Am I making sence for you ? Link to comment https://forums.phpfreaks.com/topic/104120-where-would-i-add-this-part-of-php-to-this-part-of-php/#findComment-533080 Share on other sites More sharing options...
BlueSkyIS Posted May 4, 2008 Share Posted May 4, 2008 there is nothing you can do on a "HTML" page that you can't do in a PHP page. Why change the file extension? Link to comment https://forums.phpfreaks.com/topic/104120-where-would-i-add-this-part-of-php-to-this-part-of-php/#findComment-533086 Share on other sites More sharing options...
ady01 Posted May 4, 2008 Share Posted May 4, 2008 Well it makes more sence to have your PHP script embedded in html Link to comment https://forums.phpfreaks.com/topic/104120-where-would-i-add-this-part-of-php-to-this-part-of-php/#findComment-533090 Share on other sites More sharing options...
Robert Elsdon Posted May 4, 2008 Author Share Posted May 4, 2008 I Totaly understand ill try the <?php include ('login.php') ?> Thansk for your suggestion. Link to comment https://forums.phpfreaks.com/topic/104120-where-would-i-add-this-part-of-php-to-this-part-of-php/#findComment-533091 Share on other sites More sharing options...
BlueSkyIS Posted May 4, 2008 Share Posted May 4, 2008 Well it makes more sence to have your PHP script embedded in html (sense) Why? Besides, you can't embed PHP in HTML unless you configure the server to parse HTML as PHP. If you embed in PHP, you'll have to modify Apache configuration to parse HTML as PHP. Link to comment https://forums.phpfreaks.com/topic/104120-where-would-i-add-this-part-of-php-to-this-part-of-php/#findComment-533093 Share on other sites More sharing options...
BlueSkyIS Posted May 4, 2008 Share Posted May 4, 2008 I Totaly understand ill try the <?php include ('login.php') ?> Thansk for your suggestion. unless your server is configured to parse .html as PHP, that will only display the following: <?php include('login.php'); ?> A PHP file doesn't even have to have any PHP in it. This is a valid PHP file: <HTML> <BODY> something here. </BODY> </HTML> you can use HTML in a PHP file wherever you want without re-configuring your server. Link to comment https://forums.phpfreaks.com/topic/104120-where-would-i-add-this-part-of-php-to-this-part-of-php/#findComment-533094 Share on other sites More sharing options...
ady01 Posted May 4, 2008 Share Posted May 4, 2008 Appologies for confusion guys I mean have your normal web page (your html part) then include your php with : This way you can include the two parts of your PHP without any hassle . <!--#include file="example.php" --> Link to comment https://forums.phpfreaks.com/topic/104120-where-would-i-add-this-part-of-php-to-this-part-of-php/#findComment-533100 Share on other sites More sharing options...
BlueSkyIS Posted May 4, 2008 Share Posted May 4, 2008 Appologies for confusion guys I mean have your normal web page (your html part) then include your php with : This way you can include the two parts of your PHP without any hassle . <!--#include file="example.php" --> that also won't work. first, you have to turn on the ability to use includes, your file name will have to end in .shtml (unless you change another configuration) and then the include will include the PHP code without parsing it. the only way to 'include' PHP in HTML is to configure Apache to parse HTML as PHP. No offense, but have you ever written any PHP? Link to comment https://forums.phpfreaks.com/topic/104120-where-would-i-add-this-part-of-php-to-this-part-of-php/#findComment-533102 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.