dewbie Posted May 9, 2006 Share Posted May 9, 2006 I have decided that its about time I got up to speed with PHP.I'm using my PlusNet account for hosting and for the MySQL database (which I created using phpmyadmin)I am trying to create a v.simple login site just to get used to working with the code etc..I have created a database: dewbie_pnI have created a table: membersIn this table I have: Id, username, password. I have put in 3 users details.------------------------------------------------------------------------------------Now, my problem is getting these pages on the net so they work!!I've tried uploading them to my usual ftp.plus.net account, whenever I try to open main_login.php it askes if I want to save the file to disc instead of opening the page.I tried uploading it to my cshell.plus.net and ccgi.plus.net parts of my web space, and for this I just get an error message (You don't have permission to access / on this server.)Now this is really nooby of me, but what am I doing wrong?!------------------------------------------------------------------------------------Here is a list of the code for the 3 pages.[b]main_login.php[/b](this is a login page where the 3 users I have created login with their usernam and password)[code]<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"><tr><form name="form1" method="post" action="checklogin.php"><td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"><tr><td colspan="3"><strong>Member Login </strong></td></tr><tr><td width="78">Username</td><td width="6">:</td><td width="294"><input name="myusername" type="text" id="myusername"></td></tr><tr><td>Password</td><td>:</td><td><input name="mypassword" type="text" id="mypassword"></td></tr><tr><td> </td><td> </td><td><input type="submit" name="Submit" value="Login"></td></tr></table></td></form></tr></table>[/code]This goes to this page..[b]checklogin.php[/b](checks the login details against the database)[code]<?php$host="humbug"; // Host name$username=""; // Mysql username$password=""; // Mysql password$db_name="dewbie_pn"; // Database name$tbl_name="members"; // Table name// Connect to server and select databse.mysql_connect("$host", "$username", "$password")or die("cannot connect");mysql_select_db("$db_name")or die("cannot select DB");$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";$result=mysql_query($sql);// Mysql_num_row is counting table row$count=mysql_num_rows($result);// If result matched $myusername and $mypassword, table row must be 1 rowif($count==1){// Register $myusername, $mypassword and redirect to file "login_success.php"session_register("myusername");session_register("mypassword");header("location:login_success.php");}else {echo "Wrong Username or Password";}?>[/code]If it matches, it goes to this final page...[b]login_successful.php[/b](displays a page saying "Successfuly Logged In"[code]// Check if session is not registered , redirect back to main page.// Put this code in first line of web page.<?session_start();if(!session_is_registered(myusername)){header("location:main_login.php");}?><html><body>Login Successful</body></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/9397-uploading-viewing-php-site/ Share on other sites More sharing options...
trq Posted May 9, 2006 Share Posted May 9, 2006 If its asking you if you want to download the files then its either in the wrong location or your host doesn't support php.Surely your host provides instructions on where to upload php files too? Quote Link to comment https://forums.phpfreaks.com/topic/9397-uploading-viewing-php-site/#findComment-34626 Share on other sites More sharing options...
dewbie Posted May 11, 2006 Author Share Posted May 11, 2006 Update on my problem...PlusNet told me that I do need to put it on my ccgi.plus.net space, so I did, then I realised it wasn't workign as I had put it in the cgi bin folder, I moved it from there into the main directory and got this error message:[img src=\"http://img506.imageshack.us/img506/5639/php39um.jpg\" border=\"0\" alt=\"IPB Image\" /]I then tried loading it onto the KK space, just to see if it worked, and it did! However, I have problems with this bit if anyone can help me... also ideas why it isnt working on my plusnet space when it does on KK's, even though PlusNet claim that their ccgi supports PHP.. maybe they dont have PHP installed on my ccgi space?!This is the bit of code that is wrong, I need to know what to put in for $host as it doesnt seem to like ccgi.plus.net ot humbug..[b][!--coloro:red--][span style=\"color:red\"][!--/coloro--]$host="humbug"; // Host name[!--colorc--][/span][!--/colorc--][/b]$username="dewbie"; // Mysql username$password="2fbe8e1fefb41176"; // Mysql password$db_name="dewbie_pn"; // Database name$tbl_name="members"; // Table name Quote Link to comment https://forums.phpfreaks.com/topic/9397-uploading-viewing-php-site/#findComment-35198 Share on other sites More sharing options...
.josh Posted May 11, 2006 Share Posted May 11, 2006 99.999% of the time the host should be 'localhost'$host="localhost"; // Host nameput it in just like that. Quote Link to comment https://forums.phpfreaks.com/topic/9397-uploading-viewing-php-site/#findComment-35203 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.