WebWork Magazin - Webseiten erstellen lassen, Online Medien, html

Webhoster, Webhosting Provider und Domain registrieren

Home | Registrieren | Einloggen | Suchen | Aktuelles | GSL-Webservice | Suleitec Webhosting
Reparatur-Forum | Elektro forum | Ersatzteilshop Haushalt und Elektronik


Homepage und Webhosting-Forum

Scripte und Programme für PHP, MYSQL. Diskussionen zur Programmierung im Web. Fragen zu CMS, Blogsoftware, Shops, Newsletter und vielen weiteren Scripten.


Forum » PHP & MySQL » schreibt nicht in DB :( » Antworten
Benutzername:
Passwort: Passwort vergessen?
Inhalt der Nachricht: Fett | Kursiv | Unterstrichen | Link | Bild | Smiley | Zitat | Zentriert | Quellcode| Kleiner Text
Optionen: Emailbenachrichtigung bei Antworten
 

Die letzten 5 Postings in diesem Thema » Alle anzeigen
von paul
danke, hab schon erldeigt.
der query was völlig falsch!

Liebe Grüße, PAul
von michaelh
Trag das mal ein:
echo mysql_error();
von paul
die connection muss bestehen, da ich, wenn ich einen datensatz in phpmyadmin gemacht hab mich mit dem einloggen kann. hm.
von MCM
Hab jetzt keinen fehler gefunden, aber hast du mal geguckt, ob der script überhaupt die DB-Verbindung herstellt??
von paul
hi ihr,
ich mal wieder:

ich versuche grad ein kleines login script zu schreiben.

doch leider, wenn sich ein user regsitriert : // function register ()
schreibt das ding die Daten nicht in die Datenbank!

hoffe ihr könnt mir helfen.

code:



PHP:--------------------------------------------------------------------------------

<?
session_start ();

$connection_file = "connect.php";
include ($connection_file);

mysql_select_db ("usr_web9_1 ");

function login () {

if (isset ($_POST['submit'])) {

$abfrage = "SELECT * FROM loginscript";
$ergebnis = mysql_query ($abfrage);

while ($row = mysql_fetch_array ($ergebnis)) {

if ($_POST['username'] == $row['username'] && $_POST['passwort'] == $row['passwort']) {
$_SESSION['login'] == "geloggt";
echo login_true ();
}

else {
echo "deine anmeldung schlug fehl. falsches passwort oder username";
}
}

}
else {
echo login_form ();
}
}

function login_form () {
?>
<form action="<? echo $PHP_SELF; ?>" method="post">
<table cellpadding="0" align="center" cellspacing="0">
<tr>
<td>Username:</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>Passwort:</td>
<td><input type="password" name="passwort"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="Login"></td>
</tr>
<tr>
<td><a href="?cat=register" class="impressum" style="color: black;">Registrieren</a></td>
</tr>
</table>
</form>
<?
}

function login_true () {
?>
<form action="<? echo $PHP_SELF; ?>" method="post">
<table cellpadding="0" align="center" cellspacing="0">
<tr>
<td>Du bist eingeloggt!!!</td>
</tr>
</table>
</form>
<?
}

function register () {

if (isset ($_POST['submit'])) {

$max_alter = "17";

if (!$_POST['vorname'] == "" || !$_POST['nachname'] == "" || !$_POST['passwort1'] == "" || !$_POST['passwort2'] == "" || !$_POST['passwort1'] == "" || !$_POST['username'] == "") {

if ($_POST['passwort1'] != $_POST['passwort2']) {
echo "Die anggebenen Passwörter stimmen nicht miteinander überein!";
}

elseif ($_POST['alter'] < $max_alter) {
echo "sorry du bist zu alt, das ist für jugendliche nicht für dich ";
}

else {
$abfrage = "INSERT INTO loginscript (name,nachname,email,passwort,username,status) VALUES ('$_POST[vorname],'$_POST[nachname]','$_POST[email ]','$_POST[passwort1],'$_POST[username]','nonaktiv')";
$ergebnis = mysql_query ($abfrage);
echo "bitte chech deine emails";
}

}
else {
echo "bitte fülle alle felder aus <a href=\"java script: histroy.back(-1)\">Zurück</a>";
}
}
else {
?>
<form action="<? echo $PHP_SELF; ?>" method="post">
<table align="center" cellpaddding="0" cellspacing="0">
<tr>
<td>Hallo in der 8.Klasse Community.<br />Wenn du dich hier anmeldest, stehen dir alle Türen der Seite offen.<br />PRobiers doch einfach aus. Testen kostet nix </td>
</tr>
<tr>
<td colspan="2"><br /></td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><strong>Persönliche Angaben:</strong></td>
</tr>
<tr>
<td>Vorname:</td>
<td><input type="text" name="vorname"></td>
</tr>
<tr>
<td>Nachname:</td>
<td><input type="text" name="nachname"></td>
</tr>
<tr>
<td colspan="2"><strong>Dein Wunsch Passwort</strong></td>
</tr>
<tr>
<td>Passwort:</td>
<td><input type="password" name="passwort1"></td>
</tr>
<tr>
<td>Wiederholen:</td>
<td><input type="password" name="passwort2"></td>
</tr>
<tr>
<td colspan="2"><strong>Angaben für uns:</strong></td>
</tr>
<tr>
<td>Username:</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>Dein Alter:</td>
<td>
<select size="1" name="alter">
<option value="17">1-17</option>
<option value="18">oder älter</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit" name="submit"></td>
</tr>
</table>
</td>
</tr>
</table>
<?
}

}

switch ($cat) {
case "register":
echo register ();
break;

default:
echo login ();
}
?>

--------------------------------------------------------------------------------


Liebe Grüße, Paul

Nach oben