Not displaying correct template

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
Aleeious
Posts: 55
Joined: Tue Sep 13, 2011 1:22 pm

Not displaying correct template

Post by Aleeious »

I am trying to get my code to display a different form depending on wither the form was submitted or not. However for some reason the same form is displayed even if the form is submitted. Here is the code I am using:

Code: Select all

01   <?php
02	 
03	    // include smarty library
04	    include('libs/Smarty.class.php');
05	 
06	    // create new instance of smarty object
07	    $smarty = new Smarty;
08	 
09	    // if the form was submitted
10	    if(isset($_POST["submit"]))
11	    {
12	        // set error message
13	        $smarty->assign("error", "Registrations are currently disabled!");
14	 
15	        // display the form
16	        $smarty->display('error.tpl');
17	    } else {
18	 
19	    // display the form
20	    $smarty->display('register.tpl');
21	}
22	 
23	?>
And heres the form code:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Application Form for Enployment in Aleeious Dealership!</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="templates/css/style.css" />
</head>
<body>
<h1>Congratulations!</h1>
<p>You have taken the first step in becoming one of the elite. Just fill out the application form below and we'll get you setup with your own repair bay.</p>
<form action="register.php" method="post">
<fieldset>
<label for="username">Username:</label><input type="text" name="username" id="username" title="Your mechanic's name" accesskey="1" />
<label for="password">Password:</label><input type="password" name="password" id="password" title="A Secret Password, don't tell anyone not even your best friend!" accesskey="2" />
<label for="retypepassword">Retype Password:</label><input type="password" id="retypepassword" name="retypepassword" title="Retype your secret password to make sure you didn't make any mistakes" accesskey="3" />
<label for="email">Email:</label><input type="text" name="email" id="email" title="Email address in case you forget your password" accesskey="4" />
<input type="submit" value="enlist" title="Click here after double-checking the info above to signup" accesskey="5" />
</fieldset>
</form>
</body>
</html>
Any assistance would be greatly appreciated.

Sincerely,

Aleeious
Winawer
Posts: 180
Joined: Wed Aug 17, 2011 5:53 am

Re: Not displaying correct template

Post by Winawer »

Your submit button is missing the name attribute (name="submit").
Post Reply

Return to “Beginner Help and Support”