Imothep Posted July 31, 2006 Share Posted July 31, 2006 Hello guys.. i want to run multiple scripts on the index page for different forms on the page example: login & registration. But when i use the scripts on the website they start outputting. How can i prevent this ? I want them to do something if the submit button for the forms have been pressed.Thank you .. i know im not very good at explaining. :( Link to comment https://forums.phpfreaks.com/topic/16082-running-multiple-scripts-on-index-page/ Share on other sites More sharing options...
Orio Posted July 31, 2006 Share Posted July 31, 2006 Can you give an example? I am having a hard time understanding your problem.Orio. Link to comment https://forums.phpfreaks.com/topic/16082-running-multiple-scripts-on-index-page/#findComment-66255 Share on other sites More sharing options...
Imothep Posted July 31, 2006 Author Share Posted July 31, 2006 Lets say i have the index.php site. And i want it to do different things. Lets use "login" as an example. when i call the login script. I want it to take the script from the index.php page. Not call a script outside index.php. so i dont have to make many different pages.This is an example of the html code i have for my login form on "index.php" as you can see it calls an internal page with the login script in it.But if i try to do what i want to do.. changing <form action="index.php" <--- to this. it starts to output the echo statements i made in the login scripts. There must be some way of stopping the scripts to output before you have called it.?[code]<form id="form1" name="form1" method="post" action="login.php"> <label>Email:<br /> <input name="email" type="text" class="login" id="email" /> </label> <p> <label>Password: <input name="password" type="password" class="login" /> </label> </p> <p><input type="submit" class="login" value="Login" /></p> </form>[/code] Link to comment https://forums.phpfreaks.com/topic/16082-running-multiple-scripts-on-index-page/#findComment-66257 Share on other sites More sharing options...
BillyBoB Posted July 31, 2006 Share Posted July 31, 2006 ok let me see if i get this a little do u want to do the reg. and the login at the same time ? or do you want a pagnation ? with the get so that when they click it then it shows them the reg and by default it shows the login ? srry i typed that confusing .. :( Link to comment https://forums.phpfreaks.com/topic/16082-running-multiple-scripts-on-index-page/#findComment-66259 Share on other sites More sharing options...
Imothep Posted July 31, 2006 Author Share Posted July 31, 2006 I want all my scripts on index.php. So when i press submit for login. It takes the script from index.php. that can be done using <form action="index.php"But when i put my scripts on the index.php script.. they start outputting, and i dont want them to do that before i have called them. Link to comment https://forums.phpfreaks.com/topic/16082-running-multiple-scripts-on-index-page/#findComment-66261 Share on other sites More sharing options...
BillyBoB Posted July 31, 2006 Share Posted July 31, 2006 so u want the registration and login on the same page if so this would be like an example:[code]<form method="POST"><input type="text" name="name" size="10" /><br /><input type="password" name="pass" size="10" /><br /><input type="submit" name="login" Value="LOGIN" /><br /><br /><input type="text" name="rname" size="10" /><br /><input type="password" name="rpass" size="10" /><br /><input type="password" name="rcpass" size="10" /><br /><input type="text" name="remail" size="10" /><br /><input type="submit" name="reg" value="REGISTER" /></form><?phpif($_POST[login]){ // then do this with the $_POST[name] and $_POST[pass]}if($_POST[reg]){ // then do this with the $_POST[rname], $_POST[rpass], $_POST[rcpass], and $_POST[remail]{?>[/code]plz notefy me if this helped i dont want to stay up all night thinking i didnt help u and your goin to reply :) :) Link to comment https://forums.phpfreaks.com/topic/16082-running-multiple-scripts-on-index-page/#findComment-66264 Share on other sites More sharing options...
kenrbnsn Posted July 31, 2006 Share Posted July 31, 2006 The way to do this is something like the following:[code]<?phpif (isset($_POST['submit'])) { // do this block if the submit key has been set switch($_POST['submit']) { // make sure each submit button has a different value case 'Send Registration'://// code to process registration// break; case 'Login'://// code to process login// break; } // end of switch} else { // code block to execute when neither form has been used if (isset($_GET['register'])) {// I am assuming that the login form will be displayed by default and the user has to click a link to get the registration form?> <form method="POST" action="<?php echo $_SERVER['SELF'];?> > <input type="submit" name="submit" value="Send Registration"> </form><?php } else { // display login form?> <form ...> <input type="submit" name="submit" value="Login"> </form><?php }?>[/code]The above is very rough.Ken Link to comment https://forums.phpfreaks.com/topic/16082-running-multiple-scripts-on-index-page/#findComment-66296 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.