Jump to content

Archived

This topic is now archived and is closed to further replies.

Imothep

Running multiple scripts on index page!

Recommended Posts

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. :(

Share this post


Link to post
Share on other sites
Can you give an example? I am having a hard time understanding your problem.

Orio.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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 .. :(

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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>

<?php
if($_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 :) :)

Share this post


Link to post
Share on other sites
The way to do this is something like the following:
[code]<?php
if (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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.