Jump to content


Photo

Running multiple scripts on index page!


  • Please log in to reply
6 replies to this topic

#1 Imothep

Imothep
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 31 July 2006 - 08:07 AM

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

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 31 July 2006 - 08:20 AM

Can you give an example? I am having a hard time understanding your problem.

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 Imothep

Imothep
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 31 July 2006 - 08:27 AM

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.?


<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>


#4 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 31 July 2006 - 08:40 AM

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

#5 Imothep

Imothep
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 31 July 2006 - 08:44 AM

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.

#6 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 31 July 2006 - 08:55 AM

so u want the registration and login on the same page if so this would be like an example:

<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]
{
?>

plz notefy me if this helped i dont want to stay up all night thinking i didnt help u and your goin to reply :) :)

#7 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 31 July 2006 - 11:56 AM

The way to do this is something like the following:
<?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
    }
?>

The above is very rough.

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users