vOlcer
Mitglied
Hallo zusammen, ich bin am verzweifeln 
habe 100 Tutorials gefunden wie man per Ajax und PHP mysql-Einträge AUSLIEST, aber eben nicht wie man FormularEinträge IN eine mysql-DB schreiben kann! kann mir da bitte jemand helfen, was ich bis jetzt habe:
forumal:
php:
vielen Dank für die Hilfe schon jetzt

habe 100 Tutorials gefunden wie man per Ajax und PHP mysql-Einträge AUSLIEST, aber eben nicht wie man FormularEinträge IN eine mysql-DB schreiben kann! kann mir da bitte jemand helfen, was ich bis jetzt habe:
forumal:
HTML:
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
document.myForm.time.value = ajaxRequest.responseText;
}
}
var name = document.getElementById('name').value;
var address = document.getElementById('address').value;
var plzcity = document.getElementById('plzcity').value;
var phone = document.getElementById('phone').value;
var opentimes = document.getElementById('opentimes').value;
var shortinfo = document.getElementById('shortinfo').value;
var queryString = "?name=" + name + "&address=" + address + "&plzcity=" + plzcity + "&phone=" + phone + "&opentimes=" + opentimes + "&shortinfo=" + shortinfo;
try {
ajaxRequest.open("GET", "../action/DBwriter.php" + queryString, true);
alert("Daten wurden eingetragen!");
} catch (e) {
alert("Daten konnten nicht eingetragen werden!");
}
ajaxRequest.send(null);
}
//-->
</script>
<form name="myform">
<table>
<tr>
<td>Name</td>
<td><input type="text" id="name"></td>
</tr>
<tr>
<td>Addresse</td>
<td><input type="text" id="address"></td>
</tr>
<tr>
<td>PLZ/Ort</td>
<td><input type="text" id="plzcity"></td>
</tr>
<tr>
<td>Telefon</td>
<td><input type="text" id="phone"></td>
</tr>
<tr>
<td>öffnungszeiten</td>
<td><textarea id="opentimes"></textarea></td>
</tr>
<tr>
<td>Kurz Information</td>
<td><textarea id="shortinfo"></textarea></td>
</tr>
<tr>
<td>Image</td>
<td><input type="input" id="image" disabled></td>
</tr>
<tr>
<td></td>
<td><input type='button' onclick='ajaxFunction()' value='Senden' /></td>
</tr>
</table>
</form>
php:
PHP:
<?php
$name = $_GET['name'];
$address = $_GET['address'];
$plzcity = $_GET['plzcity'];
$phone = $_GET['phone'];
$opentimes = $_GET['opentimes'];
$shortinfo = $_GET['shortinfo'];
$db = mysql_connect("xxx", "xxx", "xxx");
$sqlab = "insert into modul_info
(name,address,plzcity,phone,opentimes,shortinfo)
values
('$name','$address','$plzcity','$phone','$opentimes','$shortinfo')";
mysql_db_query("xxx", $sqlab);
?>
vielen Dank für die Hilfe schon jetzt
