Jump to content

need help with php


polardude1983

Recommended Posts

Currently I have a login screen once the person logs in it shows the persons username.  the persons username is $username

 

so what i basically want is www.mysite.com/$username/myhome.html

 

so if john logs in the when he clicks the above link it will actually say

 

www.mysite.com/john/myhome.html

 

but what it actually says is www.mysite.com/$username/myhome.html it doesnt replace the persons user name with $username

 

below is the code

 

<?php
require_once('common.php');

$error = '0';

if (isset($_POST['submitBtn'])){
// Get user input
$username = isset($_POST['username']) ? $_POST['username'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
        
// Try to login the user
$error = loginUser($username,$password);
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
   <title>Micro Login System</title>
   <link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="main">
<?php if ($error != '') {?>
      <div class="caption">Site login</div>
      <div id="icon"> </div>
      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="loginform">
        <table width="100%">
          <tr><td>Username:</td><td> <input class="text" name="username" type="text"  /></td></tr>
          <tr><td>Password:</td><td> <input class="text" name="password" type="password" /></td></tr>
          <tr><td colspan="2" align="center"><input class="text" type="submit" name="submitBtn" value="Login" /></td></tr>
        </table>  
      </form>
      
       <a href="register.php">Register</a>
      
<?php 
}   
    if (isset($_POST['submitBtn'])){

?>
      <div class="caption">Login result:</div>
      <div id="icon2"> </div>
      <div id="result">
        <table width="100%"><tr><td><br/>


<?php
if ($error == '') {
	echo '<a href="http://www.junglewebdesign.com/ '.'  $username ">here </a>'; 
	echo " $username Now you can visit the index page!";
}
else echo $error;

?>
	<br/><br/><br/></td></tr></table>
</div>
<?php            
    }
?>
<div id="source">Micro Login System v 1.0</div>
    </div>
</body>   

Link to comment
https://forums.phpfreaks.com/topic/143900-need-help-with-php/
Share on other sites

<?php
require_once('common.php');

$error = '0';

if (isset($_POST['submitBtn'])){
   // Get user input
   $username = isset($_POST['username']) ? $_POST['username'] : '';
   $password = isset($_POST['password']) ? $_POST['password'] : '';
        
   // Try to login the user
   $error = loginUser($username,$password);
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
   <title>Micro Login System</title>
   <link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="main">
<?php if ($error != '') {?>
      <div class="caption">Site login</div>
      <div id="icon"> </div>
      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="loginform">
        <table width="100%">
          <tr><td>Username:</td><td> <input class="text" name="username" type="text"  /></td></tr>
          <tr><td>Password:</td><td> <input class="text" name="password" type="password" /></td></tr>
          <tr><td colspan="2" align="center"><input class="text" type="submit" name="submitBtn" value="Login" /></td></tr>
        </table> 
      </form>
     
       <a href="register.php">Register</a>
     
<?php 
}   
    if (isset($_POST['submitBtn'])){

?>
      <div class="caption">Login result:</div>
      <div id="icon2"> </div>
      <div id="result">
        <table width="100%"><tr><td><br/>


<?php
   if ($error == '') {
      echo '<a href="http://www.junglewebdesign.com/'.$username.'/myhome.html ">here </a>'; 
      echo " $username Now you can visit the index page!";
   }
   else echo $error;

?>
      <br/><br/><br/></td></tr></table>
   </div>
<?php            
    }
?>
   <div id="source">Micro Login System v 1.0</div>
    </div>
</body>   

 

Small fix there. You didn't include the variable within the echo for the link correctly. The new code there should work fine, provided there aren't any other errors on the script.

Link to comment
https://forums.phpfreaks.com/topic/143900-need-help-with-php/#findComment-755095
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.