i'm working on a script and I want to make the links such as www.mysite.com/signup. this link for registration. www.mysite.com/user/username and this link for user's profile. the links without any php extension. also when someone request link such as www.mysite.com/signup.php should redirect him to www.mysite.com/signup
what I know is I have to create .htaccess, but what should be the code?
second problem is whith create a user session. in log in form. it works only in localhost but online it doesn't work
here is my signin.php
<?php
session_start();
require 'connect.php';
require_once 'core/classes/user_class.php';
require_once 'core/functions/main.php';
require_once 'core/functions/formfunctions.php';
include 'inc/top.php';
include 'inc/header.php';
// if there is a session
if(isset($_SESSION['username']))
{
echo '<div class="search_field"><b>you are loged in already</b></div>';
include 'inc/footer.php';
exit();
}
$username = $_POST['username'];
$userpass = $_POST['userpass'];
$user = new user();
$user->login($username,$userpass);
//form
?>
<div class="center_body">
<div class="search_field">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<td align="left">username:</td>
<td align="right"><input type="text" name="username" class="search" /></td>
</tr>
<tr>
<td align="left">userpass:</td>
<td align="right"><input type="password" name="userpass" class="search" /></td>
</tr>
</table>
<input type="submit" value="sign in" class="search" /></p>
</form>
</tr>
</div>
</div>
<?php
include 'inc/footer.php';
?>
user_class.php
public function login($username, $userpass)
{
$username = security($username);
$userpass = security(md5($userpass));
if(empty($_POST) === false)
{
if(empty($username) or empty($userpass))
{
echo '<div class="search_field"><b>معلومات الدخول خاطئه</b></div>';
}else{
$result = mysql_query("SELECT * FROM users WHERE username='$username' AND userpass='$userpass'");
while($row = mysql_fetch_assoc($result))
{
@$user = @$row['username'];
@$pass = @$row['userpass'];
}
if($username == $user and $pass == $userpass)
{
echo '<div class="search_field"><b>تم تسجيل الدخول بنجاح .. الانتقال الى الصفحه الرئيسيه</b></div></ br>';
echo'<meta http-equiv="REFRESH" content="3;url=index">';
$_SESSION['username'] = $username;
$_SESSION['userpass'] = $userpass;
}else{
echo '<div class="search_field"><b>لا يوجد عضو بهذا الاسم الرجاء تأكد من معلومات الدخول</b></div>';
}
}
}
}
hope you can help me
thank you