#cousin#
11-11-2009, 17:39
Hi Zusammen,
ich habe ein PHP-Formular generiert welches die eingegebenen Felder in eine Datenbank schrieben soll. Leider gibt es ein Problem, mein Formular schreibt nur den ersten Wert in die DB und an Stelle der andren Variablen habe ich nur Leerzeichen in der Datenbanktabelle.
Hier mal der recht lange PHP-Teil der Datei:
<?php
############################
### IP Auslesen ###
############################
$ip ="$REMOTE_ADDR";
############################
### Zufallsnummern ###
############################
$report_text_id = rand(1,3);
############################
### DB Zugriff ###
############################
$host = "localhost";
$user = "gutachten";
$password = "XXXX";
$dbname = "gutachten";
$dbverbindung = mysql_connect ($host, $user, $password);
############################
### Variablendeklaration ###
############################
if (isset($_POST['checkbox_m']))
{
$sex = "Mr";
}
if (isset($_POST['checkbox_w']))
{
$sex = "Mrs";
}
$name = $_POST['name'];
$name = str_replace("<","",$name);
$name = str_replace("\'","",$name);
$name = str_replace("'","",$name);
$name = str_replace("ä","ae",$name);
$name = str_replace("ö","oe",$name);
$name = str_replace("ü","ue",$name);
$name = str_replace("ß","ss",$name);
$name = str_replace("Ä","Ae",$name);
$name = str_replace("Ö","Oe",$name);
$name = str_replace("Ü","Ue",$name);
$first_name = $_POST['vorname'];
$first_name = str_replace("<","",$first_name);
$first_name = str_replace("\'","",$first_name);
$first_name = str_replace("'","",$first_name);
$first_name = str_replace("ä","ae",$first_name);
$first_name = str_replace("ö","oe",$first_name);
$first_name = str_replace("ü","ue",$first_name);
$first_name = str_replace("ß","ss",$first_name);
$first_name = str_replace("Ä","Ae",$first_name);
$first_name = str_replace("Ö","Oe",$first_name);
$first_name = str_replace("Ü","Ue",$first_name);
$mat_nr = $_POST['matnr'];
$mat_nr = str_replace("<","",$mat_nr);
$mat_nr = str_replace("\'","",$mat_nr);
$mat_nr = str_replace("'","",$mat_nr);
$birth_date = $_POST['"geb_tag" . "geb_monat" . "geb_jahr"'];
$birth_date = str_replace("<","",$birth_date);
$birth_date = str_replace("\'","",$birth_date);
$birth_date = str_replace("'","",$birth_date);
$birth_city = $_POST['geb_ort'];
$birth_city = str_replace("\'","",$birth_city);
$birth_city = str_replace("'","",$birth_city);
$birth_city = str_replace("ä","ae",$birth_city);
$birth_city = str_replace("ö","oe",$birth_city);
$birth_city = str_replace("ü","ue",$birth_city);
$birth_city = str_replace("ß","ss",$birth_city);
$birth_city = str_replace("Ä","Ae",$birth_city);
$birth_city = str_replace("Ö","Oe",$birth_city);
$birth_city = str_replace("Ü","Ue",$birth_city);
$birth_country = $_POST['geb_land'];
$birth_country = str_replace("\'","",$birth_country);
$birth_country = str_replace("'","",$birth_country);
$birth_country = str_replace("ä","ae",$birth_country);
$birth_country = str_replace("ö","oe",$birth_country);
$birth_country = str_replace("ü","ue",$birth_country);
$birth_country = str_replace("ß","ss",$birth_country);
$birth_country = str_replace("Ä","Ae",$birth_country);
$birth_country = str_replace("Ö","Oe",$birth_country);
$birth_country = str_replace("Ü","Ue",$birth_country);
$tel_nr = $_POST['tel_nr'];
$tel_nr = str_replace("<","",$tel_nr);
$tel_nr = str_replace("\'","",$tel_nr);
$tel_nr = str_replace("'","",$tel_nr);
$email = $_POST['email'];
$email = str_replace("<","",$email);
$email = str_replace("\'","",$email);
$email = str_replace("'","",$email);
$study_course = $_POST['studiengang'];
$study_begin = $_POST['"immat_monat" . "immat_jahr"'];
$study_begin = str_replace("<","",$study_begin);
$study_begin = str_replace("\'","",$study_begin);
$study_begin = str_replace("'","",$study_begin);
$study_end = $_POST['"end_monat" . "end_jahr"'];
$study_end = str_replace("<","",$study_end);
$study_end = str_replace("\'","",$study_end);
$study_end = str_replace("'","",$study_end);
$graduate = $_POST['abschluss'];
$report_type = $_POST['gutachten_typ'];
$comment = $_POST['comments'];
$comment = str_replace("<","",$comment);
$comment = str_replace("\'","",$comment);
$comment = str_replace("'","",$comment);
$comment = str_replace("ä","ae",$comment);
$comment = str_replace("ö","oe",$comment);
$comment = str_replace("ü","ue",$comment);
$comment = str_replace("ß","ss",$comment);
$comment = str_replace("Ä","Ae",$comment);
$comment = str_replace("Ö","Oe",$comment);
$comment = str_replace("Ü","Ue",$comment);
$uni_name = $_POST['uni_name'];
$uni_name = str_replace("<","",$uni_name);
$uni_name = str_replace("\'","",$uni_name);
$uni_name = str_replace("'","",$uni_name);
$uni_name = str_replace("ä","ae",$uni_name);
$uni_name = str_replace("ö","oe",$uni_name);
$uni_name = str_replace("ü","ue",$uni_name);
$uni_name = str_replace("ß","ss",$uni_name);
$uni_name = str_replace("Ä","Ae",$uni_name);
$uni_name = str_replace("Ö","Oe",$uni_name);
$uni_name = str_replace("Ü","Ue",$uni_name);
$uni_street = $_POST['uni_strasse'];
$uni_street = str_replace("<","",$uni_street);
$uni_street = str_replace("\'","",$uni_street);
$uni_street = str_replace("'","",$uni_street);
$uni_street = str_replace("ä","ae",$uni_street);
$uni_street = str_replace("ö","oe",$uni_street);
$uni_street = str_replace("ü","ue",$uni_street);
$uni_street = str_replace("ß","ss",$uni_street);
$uni_street = str_replace("Ä","Ae",$uni_street);
$uni_street = str_replace("Ö","Oe",$uni_street);
$uni_street = str_replace("Ü","Ue",$uni_street);
$uni_plz = $_POST['uni_plz'];
$uni_plz = str_replace("<","",$uni_plz);
$uni_plz = str_replace("\'","",$uni_plz);
$uni_plz = str_replace("'","",$uni_plz);
$uni_city = $_POST['uni_stadt'];
$uni_city = str_replace("<","",$uni_city);
$uni_city = str_replace("\'","",$uni_city);
$uni_city = str_replace("'","",$uni_city);
$uni_city = str_replace("ä","ae",$uni_city);
$uni_city = str_replace("ö","oe",$uni_city);
$uni_city = str_replace("ü","ue",$uni_city);
$uni_city = str_replace("ß","ss",$uni_city);
$uni_city = str_replace("Ä","Ae",$uni_city);
$uni_city = str_replace("Ö","Oe",$uni_city);
$uni_city = str_replace("Ü","Ue",$uni_city);
$uni_country = $_POST['uni_land'];
$uni_country = str_replace("<","",$uni_country);
$uni_country = str_replace("\'","",$uni_country);
$uni_country = str_replace("'","",$uni_country);
$uni_country = str_replace("ä","ae",$uni_country);
$uni_country = str_replace("ö","oe",$uni_country);
$uni_country = str_replace("ü","ue",$uni_country);
$uni_country = str_replace("ß","ss",$uni_country);
$uni_country = str_replace("Ä","Ae",$uni_country);
$uni_country = str_replace("Ö","Oe",$uni_country);
$uni_country = str_replace("Ü","Ue",$uni_country);
$count = $_POST['anzahl'];
############################
###DB Eintraege vornehmen###
############################
if(isset($name))
{
$db_abfrage_1 = "INSERT INTO userdata VALUES ('$id', '$name', '$first_name', '$mat_nr', '$sex', '$birth_date', '$birth_city', '$birth_country', '$tel_nr', '$email', '$study_course', '$study_begin', '$study_end', '$graduate', '$report_type', '$ip', '$comment')";
$db_abfrage_2 = "INSERT INTO report_address VALUES ('$id', '$uni_name', '$uni_street', '$uni_plz', '$uni_city', '$uni_country', '$count')";
mysql_db_query ($dbname, $db_abfrage_1, $dbverbindung);
mysql_db_query ($dbname, $db_abfrage_2, $dbverbindung);
mysql_close( $dbverbindung );
}
################################################## ################################################## ############
?>
ich habe ein PHP-Formular generiert welches die eingegebenen Felder in eine Datenbank schrieben soll. Leider gibt es ein Problem, mein Formular schreibt nur den ersten Wert in die DB und an Stelle der andren Variablen habe ich nur Leerzeichen in der Datenbanktabelle.
Hier mal der recht lange PHP-Teil der Datei:
<?php
############################
### IP Auslesen ###
############################
$ip ="$REMOTE_ADDR";
############################
### Zufallsnummern ###
############################
$report_text_id = rand(1,3);
############################
### DB Zugriff ###
############################
$host = "localhost";
$user = "gutachten";
$password = "XXXX";
$dbname = "gutachten";
$dbverbindung = mysql_connect ($host, $user, $password);
############################
### Variablendeklaration ###
############################
if (isset($_POST['checkbox_m']))
{
$sex = "Mr";
}
if (isset($_POST['checkbox_w']))
{
$sex = "Mrs";
}
$name = $_POST['name'];
$name = str_replace("<","",$name);
$name = str_replace("\'","",$name);
$name = str_replace("'","",$name);
$name = str_replace("ä","ae",$name);
$name = str_replace("ö","oe",$name);
$name = str_replace("ü","ue",$name);
$name = str_replace("ß","ss",$name);
$name = str_replace("Ä","Ae",$name);
$name = str_replace("Ö","Oe",$name);
$name = str_replace("Ü","Ue",$name);
$first_name = $_POST['vorname'];
$first_name = str_replace("<","",$first_name);
$first_name = str_replace("\'","",$first_name);
$first_name = str_replace("'","",$first_name);
$first_name = str_replace("ä","ae",$first_name);
$first_name = str_replace("ö","oe",$first_name);
$first_name = str_replace("ü","ue",$first_name);
$first_name = str_replace("ß","ss",$first_name);
$first_name = str_replace("Ä","Ae",$first_name);
$first_name = str_replace("Ö","Oe",$first_name);
$first_name = str_replace("Ü","Ue",$first_name);
$mat_nr = $_POST['matnr'];
$mat_nr = str_replace("<","",$mat_nr);
$mat_nr = str_replace("\'","",$mat_nr);
$mat_nr = str_replace("'","",$mat_nr);
$birth_date = $_POST['"geb_tag" . "geb_monat" . "geb_jahr"'];
$birth_date = str_replace("<","",$birth_date);
$birth_date = str_replace("\'","",$birth_date);
$birth_date = str_replace("'","",$birth_date);
$birth_city = $_POST['geb_ort'];
$birth_city = str_replace("\'","",$birth_city);
$birth_city = str_replace("'","",$birth_city);
$birth_city = str_replace("ä","ae",$birth_city);
$birth_city = str_replace("ö","oe",$birth_city);
$birth_city = str_replace("ü","ue",$birth_city);
$birth_city = str_replace("ß","ss",$birth_city);
$birth_city = str_replace("Ä","Ae",$birth_city);
$birth_city = str_replace("Ö","Oe",$birth_city);
$birth_city = str_replace("Ü","Ue",$birth_city);
$birth_country = $_POST['geb_land'];
$birth_country = str_replace("\'","",$birth_country);
$birth_country = str_replace("'","",$birth_country);
$birth_country = str_replace("ä","ae",$birth_country);
$birth_country = str_replace("ö","oe",$birth_country);
$birth_country = str_replace("ü","ue",$birth_country);
$birth_country = str_replace("ß","ss",$birth_country);
$birth_country = str_replace("Ä","Ae",$birth_country);
$birth_country = str_replace("Ö","Oe",$birth_country);
$birth_country = str_replace("Ü","Ue",$birth_country);
$tel_nr = $_POST['tel_nr'];
$tel_nr = str_replace("<","",$tel_nr);
$tel_nr = str_replace("\'","",$tel_nr);
$tel_nr = str_replace("'","",$tel_nr);
$email = $_POST['email'];
$email = str_replace("<","",$email);
$email = str_replace("\'","",$email);
$email = str_replace("'","",$email);
$study_course = $_POST['studiengang'];
$study_begin = $_POST['"immat_monat" . "immat_jahr"'];
$study_begin = str_replace("<","",$study_begin);
$study_begin = str_replace("\'","",$study_begin);
$study_begin = str_replace("'","",$study_begin);
$study_end = $_POST['"end_monat" . "end_jahr"'];
$study_end = str_replace("<","",$study_end);
$study_end = str_replace("\'","",$study_end);
$study_end = str_replace("'","",$study_end);
$graduate = $_POST['abschluss'];
$report_type = $_POST['gutachten_typ'];
$comment = $_POST['comments'];
$comment = str_replace("<","",$comment);
$comment = str_replace("\'","",$comment);
$comment = str_replace("'","",$comment);
$comment = str_replace("ä","ae",$comment);
$comment = str_replace("ö","oe",$comment);
$comment = str_replace("ü","ue",$comment);
$comment = str_replace("ß","ss",$comment);
$comment = str_replace("Ä","Ae",$comment);
$comment = str_replace("Ö","Oe",$comment);
$comment = str_replace("Ü","Ue",$comment);
$uni_name = $_POST['uni_name'];
$uni_name = str_replace("<","",$uni_name);
$uni_name = str_replace("\'","",$uni_name);
$uni_name = str_replace("'","",$uni_name);
$uni_name = str_replace("ä","ae",$uni_name);
$uni_name = str_replace("ö","oe",$uni_name);
$uni_name = str_replace("ü","ue",$uni_name);
$uni_name = str_replace("ß","ss",$uni_name);
$uni_name = str_replace("Ä","Ae",$uni_name);
$uni_name = str_replace("Ö","Oe",$uni_name);
$uni_name = str_replace("Ü","Ue",$uni_name);
$uni_street = $_POST['uni_strasse'];
$uni_street = str_replace("<","",$uni_street);
$uni_street = str_replace("\'","",$uni_street);
$uni_street = str_replace("'","",$uni_street);
$uni_street = str_replace("ä","ae",$uni_street);
$uni_street = str_replace("ö","oe",$uni_street);
$uni_street = str_replace("ü","ue",$uni_street);
$uni_street = str_replace("ß","ss",$uni_street);
$uni_street = str_replace("Ä","Ae",$uni_street);
$uni_street = str_replace("Ö","Oe",$uni_street);
$uni_street = str_replace("Ü","Ue",$uni_street);
$uni_plz = $_POST['uni_plz'];
$uni_plz = str_replace("<","",$uni_plz);
$uni_plz = str_replace("\'","",$uni_plz);
$uni_plz = str_replace("'","",$uni_plz);
$uni_city = $_POST['uni_stadt'];
$uni_city = str_replace("<","",$uni_city);
$uni_city = str_replace("\'","",$uni_city);
$uni_city = str_replace("'","",$uni_city);
$uni_city = str_replace("ä","ae",$uni_city);
$uni_city = str_replace("ö","oe",$uni_city);
$uni_city = str_replace("ü","ue",$uni_city);
$uni_city = str_replace("ß","ss",$uni_city);
$uni_city = str_replace("Ä","Ae",$uni_city);
$uni_city = str_replace("Ö","Oe",$uni_city);
$uni_city = str_replace("Ü","Ue",$uni_city);
$uni_country = $_POST['uni_land'];
$uni_country = str_replace("<","",$uni_country);
$uni_country = str_replace("\'","",$uni_country);
$uni_country = str_replace("'","",$uni_country);
$uni_country = str_replace("ä","ae",$uni_country);
$uni_country = str_replace("ö","oe",$uni_country);
$uni_country = str_replace("ü","ue",$uni_country);
$uni_country = str_replace("ß","ss",$uni_country);
$uni_country = str_replace("Ä","Ae",$uni_country);
$uni_country = str_replace("Ö","Oe",$uni_country);
$uni_country = str_replace("Ü","Ue",$uni_country);
$count = $_POST['anzahl'];
############################
###DB Eintraege vornehmen###
############################
if(isset($name))
{
$db_abfrage_1 = "INSERT INTO userdata VALUES ('$id', '$name', '$first_name', '$mat_nr', '$sex', '$birth_date', '$birth_city', '$birth_country', '$tel_nr', '$email', '$study_course', '$study_begin', '$study_end', '$graduate', '$report_type', '$ip', '$comment')";
$db_abfrage_2 = "INSERT INTO report_address VALUES ('$id', '$uni_name', '$uni_street', '$uni_plz', '$uni_city', '$uni_country', '$count')";
mysql_db_query ($dbname, $db_abfrage_1, $dbverbindung);
mysql_db_query ($dbname, $db_abfrage_2, $dbverbindung);
mysql_close( $dbverbindung );
}
################################################## ################################################## ############
?>