|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
brokedev Smarty n00b
Joined: 06 Dec 2016 Posts: 3
|
Posted: Tue Dec 06, 2016 3:36 pm Post subject: redirect on the wrong page |
|
|
Hi, i already excuse for my bad english i'm french,
i have a problem with smarty
i make a form upload with smarty but when i clik on the send button smarty redirect on the index.php and don't use the fonction the send button call i don't know here my code.
index page
Code: | <?php
require_once("libs/Smarty.class.php");
require_once("includes/connect_db.php");
session_start();
if (isset($_POST['username'])) {
// Set variables to represent data from database
$dbUsername = "??";
$dbPassword = "??";
$uid = "?";
// Set the posted data from the form into local variables
$username = strip_tags($_POST['username']);
$paswd = strip_tags($_POST['password']);
// Check if the username and the password they entered was correct
if ($username == $dbUsername && $paswd == $dbPassword) {
// Set session
$_SESSION['username'] = $username;
$_SESSION['id'] = $uid;
if (isset($_POST['upload'])){
//Upload d'un fichier
$file = _Upload();
$url = "http://@ip/appli/marco/session1/" . $file;
if(isset($_POST['choix'])) {
// Envoie mail
_mail($url, $_POST['choix']);
}
}
$tpl = new Smarty();
$tpl->assign("titre", "DaafBox");
$tpl->assign("msgaccueil", "Bienvenue sur DaafBox");
$tpl->assign("msgaide", "Ici vous pourrez déposer vos fichiers à partager");
$tpl->assign("msgordre", "Echanger un fichier");
$tpl->display('user.tpl');
}
else {
echo "Identifiant incorrect, réeesayer";
header("Refresh:1; url=index1.php");
}
}
else
{
$tpl = new Smarty();
$tpl->assign("titre", "DaafBox");
$tpl->assign("msgaccueil", "Bienvenue sur DaafBox");
$tpl->assign("msgaide", "Ici vous pourrez déposer vos fichiers à partager");
$tpl->assign("msgordre", "Commencez par vous identifier");
$tpl->display('index.tpl');
}
?>
|
Code: | <!DOCTYPE html>
<html lang="fr">
<head>
<link href='http://fonts.googleapis.com/css?family=Roboto:400,300,500,100' rel='stylesheet' type='text/css'>
<link rel='stylesheet' href='style.css'/>
<meta charset ="UTF-8">
<title>{$titre}</title>
</head>
<body>
<h1>{$msgaccueil}</h1>
<h2>{$msgaide}</h2>
<h3>{$msgordre}</h3> <br>
<form id="form" action="index1.php" method="post" enctype="multipart/form-data">
Username: <input type="text" name="username" /> <br />
Password: <input type="password" name="password" /> <br />
<input type="submit" class="btn-logout" value="Login" name="Submit" />
</form>
</body>
</html> |
the user.tpl Code: | <!DOCTYPE html>
<html lang="fr">
<head>
<link href='http://fonts.googleapis.com/css?family=Roboto:400,300,500,100' rel='stylesheet' type='text/css'>
<link rel='stylesheet' href='style.css'/>
<meta charset ="UTF-8">
<title>{$titre}</title>
</head>
<body>
<div id="wrapper">
<h1>{$msgaccueil}</h1>
<h2>{$msgaide}</h2>
<h3>{$msgordre}</h3>
<form id="form" action="" method="POST" enctype="multipart/form-data">
<input type="file" id="fichier" class="btn-files" name="fichier" /> <br/>
<select name="choix">
<option> Anthony.Martial14</option>
<option> Walter.Nicot</option>
<option> Audrey.Nicot</option>
</select>
<input type="submit" id="upload" name="upload" class="btn-upload" value="Envoyer le fichier"/>
</form>
<p><a href="logout.php" class="btn-logout">Déconnexion</a></p>
</body>
</html> |
the index.tpl run right and redirect me on the user.tpl but the user.tpl don't run right when a i clik on the upload button i redirected on the index.php
thanks for your awnser if you understand me. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue Dec 06, 2016 6:39 pm Post subject: |
|
|
What you must understand is that the page you see in browser has no knowledge of the code it was generated from.
It's just a plain HTML document.
If you generated it wrong, then you have to fix the code that generates it.
If it contains wrong links, then YOU put these wrong links in there. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|