whiteboikyle Posted June 3, 2008 Share Posted June 3, 2008 Okay well i have a register form setup.. and i have a process.php setup as well.. Well when it goes to process it fails in the isset. Register.php <?php include("header.inc"); ?> <form method="POST" action="process.php"> <div align="center"> <table width="300" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="154" style="border-width: 1px; border-style:solid; border-color:#000000"><div align="right">Username:</div></td> <td width="146" style="border-width: 1px; border-style:solid; border-color:#000000"><input type="text" name="username" /></td> </tr> <tr> <td style="border-width: 1px; border-style:solid; border-color:#000000"><div align="right">Password:</div></td> <td style="border-width: 1px; border-style:solid; border-color:#000000"><input type="text" name="password" /></td> </tr> <tr> <td style="border-width: 1px; border-style:solid; border-color:#000000"><div align="right">Email:</div></td> <td style="border-width: 1px; border-style:solid; border-color:#000000"><input type="text" name="email" /></td> </tr> <tr> <td colspan="2"><div align="center"> <input type="hidden" name"register" value="1"> <input type="submit" name="Submit" value="Submit" /> <input type="reset" name="reset" value="Reset" /> </div></td> </tr> </table> </div> </form> <?php include("footer.inc"); ?> Process.php <?php require("include/constants.php"); class Process { function Process(){ if(isset($_POST['register'])) { $this->register(); } else { header("Location: main.php"); } } function register(){ $username = $_POST["username"]; $password = $_POST["password"]; $email = $_POST["email"]; $query = "INSERT INTO members (ID, username, password, email) VALUES (NULL, '$username', '$password', '$email')"; mysql_query($query, @mysql_connect(DB_SERVER, DB_USER, DB_PASS)) or die(mysql_error()); echo("<center><font size='4'><font color='red'>Post has been submitted! Will redirect in 2 seconds</center></font>"); echo("<META HTTP-EQUIV='refresh' CONTENT='2;news.php'>"); } }; $process = new Process; ?> When it submits it goes to Main.php instead of going to news.php like i wanted it to. Quote Link to comment Share on other sites More sharing options...
burnside Posted June 3, 2008 Share Posted June 3, 2008 ("<META HTTP-EQUIV='refresh' CONTENT='2;url=news.php'>"); missed the url bit off. Quote Link to comment Share on other sites More sharing options...
whiteboikyle Posted June 3, 2008 Author Share Posted June 3, 2008 no thats not the problem.. the if statement is failing Quote Link to comment Share on other sites More sharing options...
beboo002 Posted June 3, 2008 Share Posted June 3, 2008 isset() return true and false (1 or 0) isset check both if and else condition I Think becouse you have given 2 second to redirect the page and else section excuted before thats why it gose to main.php for better result u use if then else condition Quote Link to comment Share on other sites More sharing options...
eldorik Posted June 3, 2008 Share Posted June 3, 2008 <input type="hidden" name"register" value="1"> You are missing the = for the name parameter, which would not let that value show up in the $_POST array <input type="hidden" name="register" value="1"> That should work Quote Link to comment Share on other sites More sharing options...
Wolphie Posted June 3, 2008 Share Posted June 3, 2008 First of all, add error_reporting(E_ALL); to the top of your script so you can find out where the actual problem lies. Secondly, you don't need the hidden field. You can check if the POST data is set on the submit button. Use some indication about whether it was successful or not rather than executing some more code, or re-directing. You forgot the '=' on the name parameter also. EDIT: Sorry, eldorik got there before me. <?php class MyClass { function MyClass() { if(isset($_POST['submit'])) print 'Successful'; else print 'Failed'; } } $class = new MyClass(); // Note the parenthesis. ?> Quote Link to comment Share on other sites More sharing options...
whiteboikyle Posted June 3, 2008 Author Share Posted June 3, 2008 First of all, add error_reporting(E_ALL); to the top of your script so you can find out where the actual problem lies. Secondly, you don't need the hidden field. You can check if the POST data is set on the submit button. Use some indication about whether it was successful or not rather than executing some more code, or re-directing. You forgot the '=' on the name parameter also. EDIT: Sorry, eldorik got there before me. <?php class MyClass { function MyClass() { if(isset($_POST['submit'])) print 'Successful'; else print 'Failed'; } } $class = new MyClass(); // Note the parenthesis. ?> i am using process.php for more then just 1 submit... so that is why i will be using the Hidden Variable Quote Link to comment Share on other sites More sharing options...
Wolphie Posted June 4, 2008 Share Posted June 4, 2008 If that's the case, give each submit input a unique name. Less HTML decreases page load time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.