Hi,
mein problem ist:
ich habe ein loginscript, welches hervorragend funktioniert.
Jedoch will ich bei einer Bestellung, dass sich der username automatisch ausfüllt. (es sind 1-2 andere Seiten dawischen)
Ich hab schon vieles probiert jedoch ohne Erfolg, da ich noch ein ziemlicher Anfänger bin.
Fürs Loginscript hab ich 3 Datein:
main_login.php in der das Formular zum Login ist.
	
checklogin.php wo sich die Logik zum überprüfen der Formulardaten befindet:
	
login_success.php, in der lediglich weitererlinkt wird wenn alles richtig eingegeben wurde
	
Das hier ist das Bestellungsformular in das sich der username dann automatisch schreiben soll:
	
Ich hoffe ihr wisst wie ich es hinbekommen kann.
Danke im Vorraus!
Gruß Torfu
					mein problem ist:
ich habe ein loginscript, welches hervorragend funktioniert.
Jedoch will ich bei einer Bestellung, dass sich der username automatisch ausfüllt. (es sind 1-2 andere Seiten dawischen)
Ich hab schon vieles probiert jedoch ohne Erfolg, da ich noch ein ziemlicher Anfänger bin.
Fürs Loginscript hab ich 3 Datein:
main_login.php in der das Formular zum Login ist.
PHP-Code:
	
	
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>DB Login</strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="text"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table> 
PHP-Code:
	
	
<?php
$host="localhost"; // Host name
$username="username"; // Mysql username
$password="dbpw"; // Mysql password
$db_name="dbname"; // Database name
$tbl_name="login"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
?>
<?php
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
?>
bestellung.php?username=$myusername
<?
}
else {
echo "Wrong Username or Password";
}
?>
PHP-Code:
	
	
<?
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>
<html>
<body>
Login Successful<br>
<a href='db_index.html'>Zur DB</a>
</body>
</html>
PHP-Code:
	
	
<?
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test DB</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
  <p align="center">  
  <b><font size="5">Ressourcenbestellung</font></b></p>
    <p align="center">  
  <font color="#FF0000">Alle Angaben sind in k anzugeben.</font></p>
    <p>  
   </p>
    <p>  
  <label>Titan
  <input type="text" name="Titan" id="Titan" />
  </label>
  <label>Silicium
  <input type="text" name="Silicium" id="Silicium" />
  </label>
  <label>Helium
  <input type="text" name="Helium" id="Helium" />
  </label>
  <label>Nahrung
  <input type="text" name="Nahrung" id="Nahrung" />
  </label>
  <label>Wasser
  <input type="text" name="Wasser" id="Wasser" />
  </label>
  </p>
  <p>
  <label>Bauxit
  <input type="text" name="Bauxit" id="Bauxit" />
  </label>
  <label>Aluminium
  <input type="text" name="Aluminium" id="Aluminium" />
  </label>
  <label>Uran
  <input type="text" name="Uran" id="Uran" />
  </label>
  <label>Plutonium
  <input type="text" name="Plutonium" id="Plutonium" />
  </label>
  <label>Wasserstoff
  <input type="text" name="Wasserstoff" id="Wasserstoff" />
  </label></p>
  <p>
  <label>Credits
  <input type="text" name="Credits" id="Credits" />
  </label>  
  
  <input type="submit" name="Bestellung" id="button" value="Senden"/>
  
</form>
<?php
include("connect.php");
  $user = $_GET["username"];
  $ti = $_POST["Titan"];
  $si = $_POST["Silicium"];
  $na = $_POST["Nahrung"];
  $he = $_POST["Helium"];
  $wa = $_POST["Wasser"];
  $ba = $_POST["Bauxit"];
  $al = $_POST["Aluminium"];
  $ur = $_POST["Uran"];
  $pl = $_POST["Plutonium"];
  $ws = $_POST["Wasserstoff"];
  $cr = $_POST["Credits"];
  $eintrag = "INSERT INTO Ress (User, Titan, Silicium, Helium, 
Nahrung, Wasser, Bauxit, Aluminium,
 Uran, Plutonium, Wasserstoff, Credits) 
VALUES ('$user', '$ti','$si', '$he', $na, $wa, $ba, 
$al, $ur, $pl, $ws, $cr)";
  $eintragen = mysql_query($eintrag);
?>
</body>
</html>
Danke im Vorraus!
Gruß Torfu
 
          
 Automatisch User ausfüllen
									
									
									Automatisch User ausfüllen
								 
							
						
 
							
						
Kommentar