2017-07-11 2 views
0

Ich mache einen Startknopf auf meiner Website, wo die Person seine E-Mail-Adresse eingibt und dann "Los geht's" drückt. Der Text sollte dann auf meine Login-Seite im E-Mail-Feld übertragen werden.Wie kann ich Text auf einer anderen Seite in einem Formular anzeigen lassen?

Hier ist mein Code für die Schaltfläche:

    <form method="post" action="#" class="container 50%"> 
         <div class="row uniform 50%"> 
          <div class="8u 12u$(xsmall)"><input type="email" name="email" id="email" placeholder="Your Email Address" /></div> 
          <div class="4u$ 12u$(xsmall)"><input type="button" value="Get Started" class="fit special" onclick="location.href='loginsystem/loginpage.php';"></div> 
         </div> 
        </form> 

Und hier ist mein Code für die Login-Seite:

<?php 
/* Main page with two forms: sign up and log in */ 
require 'db.php'; 
session_start(); 
?> 
<!DOCTYPE html> 
<html> 
<head> 
<title>Sign-Up/Login Form</title> 
<?php include 'css/css.html'; ?> 
</head> 
<?php 
if ($_SERVER['REQUEST_METHOD'] == 'POST') 
{ 
if (isset($_POST['login'])) { //user logging in 

    require 'login.php'; 

} 

elseif (isset($_POST['register'])) { //user registering 

    require 'register.php'; 

} 
} 
?> 
<body style="background-color: #1c1d26"> 
<div class="form"> 

    <ul class="tab-group"> 
    <li class="tab"><a href="#signup">Sign Up</a></li> 
    <li class="tab active"><a href="#login">Log In</a></li> 
    </ul> 

    <div class="tab-content"> 

    <div id="login"> 
     <h1>Welcome Back!</h1> 

     <form action="loginpage.php" method="post" autocomplete="off"> 

     <div class="field-wrap"> 
     <label> 
      Email Address<span class="req">*</span> 
     </label> 
     <input type="email" required autocomplete="off" name="email"/> 
     </div> 

     <div class="field-wrap"> 
     <label> 
      Password<span class="req">*</span> 
     </label> 
     <input type="password" required autocomplete="off" name="password"/> 
     </div> 

     <p class="forgot"><a href="forgot.php">Forgot Password?</a></p> 

     <button class="button button-block" name="login" />Log In</button> 

     </form> 

    </div> 

    <div id="signup"> 
     <h1>Sign Up for Free</h1> 

     <form action="loginpage.php" method="post" autocomplete="off"> 

     <div class="top-row"> 
     <div class="field-wrap"> 
      <label> 
      First Name<span class="req">*</span> 
      </label> 
      <input type="text" required autocomplete="off" name='firstname' /> 
     </div> 

     <div class="field-wrap"> 
      <label> 
      Last Name<span class="req">*</span> 
      </label> 
      <input type="text"required autocomplete="off" name='lastname' /> 
     </div> 
     </div> 

     <div class="field-wrap"> 
     <label> 
     Email Address<span class="req">*</span> 
     </label> 
     <input type="email"required autocomplete="off" name='email' /> 
     </div> 

     <div class="field-wrap"> 
     <label> 
     Set A Password<span class="req">*</span> 
     </label> 
     <input type="password"required autocomplete="off" name='password'/> 
     </div> 

     <button type="submit" class="button button-block" name="register" />Register</button> 

     </form> 

    </div> 

    </div><!-- tab-content --> 

    </div> <!-- /form --> 
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'>   </script> 

<script src="js/index.js"></script> 

</body> 
</html> 

Thank you!

+0

u könnte, statt innerhalb Onclick Standortwechsel zu tun, einfach macht es zu einem (https [Submit-Button]: //developer.mozilla.org/de/docs/Web/HTML/Element/button) mit type = "submit" und zB name = "submit" + füge ein [action attribut] (https://developer.mozilla.org/de/docs/Web/HTML/Element/form) in dein Formular ein, das auf deine PHP-Datei verweist - in deinem php kannst du dann Fragen Sie nach $ _POST ['submit'] und holen Sie sich die Eingabedaten von $ _POST ['email'] - btw. Sie sollten vielleicht ein wenig Zeit in HTML-Forms und wann/warum js & php oder noch besser verwenden, was ist ihr Anwendungsfall;) – MarcelD

Antwort

1

In Ihrem loszulegen formaction="yourLoginPage.php" gesetzt

<form method="post" action="yourLoginPage.php" class="container 50%"> 

In Ihrer Login-Seite

<input type="email" required autocomplete="off" name="email" value="<?php echo $_POST["email"]; ?>"/> 
Verwandte Themen