hi for all the PHP experts here, i have couple of questions that keeps me feel frustrating..
first of all, may i know how to insert a link within PHP echo?
for example, i have a function which is used to validate the username, if the username is incorrect, i need to echo a link to let the user back to the login page, and if the username is admin, i will need to direct it to the admin page, if username is user, then it will be the default page i'd created in the form's action. Here is the code:
<?php
session_start();
$_SESSION['name']=$_POST['name'];
$_SESSION['password']=$_POST['password'];
$_SESSION['status']=$_POST['status'];
if($_POST['name']=="user" || $_POST['name']=="admin")
{
// i need a link here to the pages
echo "Your username is: ".$_POST['name'];
}
else
{
die('The username provided is not valid. Please provide a correct username.');
}
if(strlen($_POST['password'])>=5 && $_POST['password']=="admin123" || $_POST['password']=="user123")
{
echo " with password: ".$_POST['password'];
}
else
{
die('.The password provided is not valid. Please provide a a correct password.');
}
?>
the second question is, about the upload, i tried to upload the file using the code shown below but unsuccessfully, here is the code:
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" >
<h1>Choose a file to upload:</h1>
<div><label><input name="uploadedfile" type="file" ><input type="submit" value="Upload File" ></label>
</div></form>
and for the uploader.php code:
<?php
$uploaddir = 'http://xxxx.xxxxxxx.com/phptryingnew_1/upload/files/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo "<p>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Upload failed";
}
echo "</p>";
echo '<pre>';
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>
is the code correct? Thanks for helping...