auriaks
04-03-2010, 04:48 PM
Hi,
I have AJAX form, which sends text to message.php page ans there text is inserted to the mysql.
Here is my message.php
<?php
if (isset($_GET['action'])) {
$nikas = $_GET['nick'];
$zinute = $_GET['zinute'];
$failas = $_GET['failas'];
$time = date("H:i:s");
include $_SERVER['DOCUMENT_ROOT'] . '/content/processes/db_conn.php'; //db
$nikas = mysql_real_escape_string($nikas);
$zinute = mysql_real_escape_string($zinute);
$failas = mysql_real_escape_string($failas);
$nikas = mysql_real_escape_string($nikas);
$zinute = str_replace('\r\n','<br \>',$zinute);
if($zinute == '') {
$error .= "Prašome įvesti tekstą.";
}
if(isset($error)) {
echo "$error";
} else {
mysql_query("INSERT INTO `pamoka_zinutes` (Nick, Time, Zinute, failas)
VALUES('$nikas', '$time', '$zinute', '$failas')") or die(mysql_error());
}}
if (isset($_GET['truncate'])) {
include $_SERVER['DOCUMENT_ROOT'] . '/content/processes/db_conn.php'; //db
$nikas = $_GET['truncate'];
$nikas = mysql_real_escape_string($nikas);
if ($nikas == 'admin') {
mysql_query("TRUNCATE TABLE `pamoka_zinutes`");
echo "Žinutės ištrintos";} else {echo "Tik mokytojas gali trinti žinutes";}
}
?>
This part should detect ENTER pushing but it doesn't
$zinute = str_replace('\r\n','<br \>',$zinute);
What is wrong?
Thanks for your time.
I have AJAX form, which sends text to message.php page ans there text is inserted to the mysql.
Here is my message.php
<?php
if (isset($_GET['action'])) {
$nikas = $_GET['nick'];
$zinute = $_GET['zinute'];
$failas = $_GET['failas'];
$time = date("H:i:s");
include $_SERVER['DOCUMENT_ROOT'] . '/content/processes/db_conn.php'; //db
$nikas = mysql_real_escape_string($nikas);
$zinute = mysql_real_escape_string($zinute);
$failas = mysql_real_escape_string($failas);
$nikas = mysql_real_escape_string($nikas);
$zinute = str_replace('\r\n','<br \>',$zinute);
if($zinute == '') {
$error .= "Prašome įvesti tekstą.";
}
if(isset($error)) {
echo "$error";
} else {
mysql_query("INSERT INTO `pamoka_zinutes` (Nick, Time, Zinute, failas)
VALUES('$nikas', '$time', '$zinute', '$failas')") or die(mysql_error());
}}
if (isset($_GET['truncate'])) {
include $_SERVER['DOCUMENT_ROOT'] . '/content/processes/db_conn.php'; //db
$nikas = $_GET['truncate'];
$nikas = mysql_real_escape_string($nikas);
if ($nikas == 'admin') {
mysql_query("TRUNCATE TABLE `pamoka_zinutes`");
echo "Žinutės ištrintos";} else {echo "Tik mokytojas gali trinti žinutes";}
}
?>
This part should detect ENTER pushing but it doesn't
$zinute = str_replace('\r\n','<br \>',$zinute);
What is wrong?
Thanks for your time.