CRUD OPERATION USING HTML and MYSQL PHP [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Notice: Undefined variable: db in C:\xampp\htdocs\xampp\index1.php on line 32
Warning: mysqli_query() expects parameter 1 to be mysqli, null given
in C:\xampp\htdocs\xampp\index1.php on line 32
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result,
null given in C:\xampp\htdocs\xampp\index1.php on line 43 Notice:
Undefined variable: update in C:\xampp\htdocs\xampp\index1.php on line
69
<!DOCTYPE html>
<html>
<head>
<title>CRUD: CReate, Update, Delete PHP MySQL</title>
</head>
<body>
<?php if (isset($_SESSION['message'])): ?>
<div class="msg">
<?php
echo $_SESSION['message'];
unset($_SESSION['message']);
?>
</div>
<?php endif?>
<?php
if (isset($_GET['edit'])) {
$id = $_GET['edit'];
$update = true;
$record = mysqli_query($db, "SELECT * FROM info WHERE id=$id");
if (count($record) == 1) {
$n = mysqli_fetch_array($record);
$name = $n['name'];
$address = $n['address'];
}
}
?>
<?php
$results = mysqli_query($db, "SELECT * FROM info");?>
<table>
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th colspan="2">Action</th>
</tr>
</thead>
<?php while ($row = mysqli_fetch_array($results)) {?>
<tr>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['address']; ?></td>
<td>
<a href="index.php?edit=<?php echo $row['id']; ?>" class="edit_btn" >Edit</a>
</td>
<td>
Delete
</td>
</tr>
<?php }?>
</table>
<form>
<form method="post" action="php_code.php" >
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div class="input-group">
<label>Name</label>
<input type="text" name="name" value="">
</div>
<div class="input-group">
<label>Address</label>
<input type="text" name="address" value="">
</div>
<div class="input-group">
<?php if ($update == true): ?>
<button class="btn" type="submit" name="update" style="background: #556B2F;" >update</button>
<?php else: ?>
<button class="btn" type="submit" name="save" >Save</button>
<?php endif?>
</div>
</form>
</body>
</html>
2ND FILE
<?php
session_start();
$db = mysqli_connect('localhost', 'root', '', 'crud');
$name = "";
$address = "";
$id = 0;
$update = false;
if (isset($_POST['save'])) {
$name = $_POST['name'];
$address = $_POST['address'];
mysqli_query($db, "INSERT INTO info (name, address) VALUES ('$name', '$address')");
$_SESSION['message'] = "Address saved";
header('location: index.php');
}
if (isset($_POST['update'])) {
$id = $_POST['id'];
$name = $_POST['name'];
$address = $_POST['address'];
mysqli_query($db, "UPDATE info SET name='$name', address='$address' WHERE id=$id");
$_SESSION['message'] = "Address updated!";
header('location: index.php');
}
if (isset($_GET['del'])) {
$id = $_GET['del'];
mysqli_query($db, "DELETE FROM info WHERE id=$id");
$_SESSION['message'] = "Address deleted!";
header('location: index.php');
}

And your code is fully prone to SQL injection
Read about the PHP Prepared statements.
https://www.w3schools.com/php/php_mysql_prepared_statements.asp
Suppose file 1 name is codefile.php and file 2 containing connection is connection.php So, write in codefile.php include("connection.php")
Change $db to $conn in codefile.php as in connection.php, you have created connection in $conn variable
Check below link:
w3schools.com/php/php_includes.asp
codefile.php
<?php
include("connection.php");
$results = mysqli_query($conn, "SELECT * FROM info");
?>
<!DOCTYPE html>
<html>
<head>
<title>CRUD: CReate, Update, Delete PHP MySQL</title>
</head>
<body>
..................
..................
..................
connection.php
<?php
session_start();
$db_host = "localhost";
$db_location = " ";
$db_name = "crud";
$conn= mysqli_connect ($db_host,$db_name, $db_location,$db_name)or die ("could not connect to mysql");
..................
..................
..................

Related

Page to update mysql entry does not run sql query

I have three pages at the moment:
config.php: contains the configuration for mysql connection
list.php: lists entries in a mysql table
edit.php: edits a specific entry selected in list.php
config.php:
define('DB_SERVER', 'server');
define('DB_USERNAME', 'user');
define('DB_PASSWORD', 'pass');
define('DB_NAME', 'database');
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
list.php:
<?php
require_once "config.php";
session_start();
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
header("location: login.php");
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<meta http-equiv="Content-type" content="text/html; charset=utf8">
<title>Bienvenue</title>
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body{ font: 14px sans-serif; text-align: center; }
</style>
</head>
<body>
<table class="table table-striped">
<tr>
<th></th>
<th>column 1</th>
<th>column 2</th>
</tr>
<?php
$result = mysqli_query($link, "select * from TABLE");
while($row = mysqli_fetch_array($result)){
echo "<tr>
<td><a href='edit.php?id=" . $row['IDCOLUMN'] . "' class='btn btn-success ml-3'>Modifier</a></td>
<td>" . $row['column 1'] . "</td>
<td>" . $row['column 2'] . "</td>
</tr>"; //$row['index'] the index here is a field name
}
mysqli_close(); //Make sure to close out the database connection
?>
</table>
</body>
</html>
edit.php:
<?php
require_once "config.php";
session_start();
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
header("location: login.php");
exit;
}
$id = $_GET['id'];
$resname_err = $rescity_err = "";
// Processing form data when form is submitted
if($_SERVER["REQUEST_METHOD"] == "POST"){
// Validate new password
if(empty(trim($_POST["nom_residence"]))){
$resname_err = "Entrer le nom de la résidence.";
} elseif(empty(trim($_POST["ville_residence"]))){
$rescity_err = "Entrer la ville de la résidence.";
}else{
$resname1 = trim($_POST["nom_residence"]);
$rescity1 = trim($_POST["ville_residence"]);
}
// Check input errors before updating the database
if(empty($resname_err) && empty($rescity_err)){
// Prepare an update statement
$sql = "UPDATE residences SET RESIDENCE = ?, VILLE = ? WHERE residenceID = ?";
if($stmt = mysqli_prepare($link, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "ssi", $resname1, $rescity1, $id);
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
header("location: list.php?=".$resname1.$rescity1);
exit();
} else{
echo "Oops! Something went wrong. Please try again later.";
}
// Close statement
mysqli_stmt_close($stmt);
}
}
}
?>
<!DOCTYPE html>
<html lang>
<head>
<meta charset="utf8">
<meta http-equiv="Content-type" content="text/html; charset=utf8">
<title>Bienvenue</title>
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<?php
$result = mysqli_query($link, "select * from residences where residenceID=".$id);
while($row = mysqli_fetch_array($result)){ //Creates a loop to loop through results
$resname = $row['RESIDENCE'];
$rescity = $row['VILLE'];
}
mysqli_close($link)
?>
<div class="wrapper">
<h2>modify entry</h2>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div class="form-group">
<label>value name1</label>
<input name="nom_residence" class="form-control <?php echo
(!empty($resname_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $resname; ?>">
<span class="invalid-feedback"><?php echo $resname_err; ?></span>
</div>
<div class="form-group">
<label>value name2</label>
<input name="ville_residence" class="form-control <?php echo
(!empty($rescity_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $rescity; ?>">
<span class="invalid-feedback"><?php echo $rescity_err; ?></span>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Enregistrer">
<a class="btn btn-link ml-2" href="list.php">Annuler</a>
</div>
</form>
</div>
</body>
</html>
My current problem is that the Mysql entry is never updated.
This section runs:
header("location: list.php?=".$resname1.$rescity1);
So I know every condition is met correctly
Note: I added this part to know their values when redirected to list.php:
.$resname1.$rescity1
I ran all the code inside a PHP shell and it worked perfectly.
Of course, I had to set the values resname1 and rescity1 manually, so I'm thinking it must be some formatting issue?

Problem in if and {endif} and {endwhile} in my first Project?

This problem in php I need solution in this day
Please for my homework
Can you help me in my homework please because I'm not working but I'm reading in my university Please can you solve this problem.
Can you explain to my this problem or can connection to my desktop to solution this problem or can send explain .
This code
index.php:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</head>
<body>
<?php require_once 'process.php'?>
<?php
if(isset ($_SESSION['message']));?>
<div class="alert alert-<?=$_SESSION['msg_type']?>">
<?php
echo $_SESSION['message'];
unset($_SESSION['message']);
// and this problem !
<?php endif ?>
?>
<div class="contener">
<?php
$mysqli = new mysqli('localhost', 'root', 'rootroot','crudcrud') or die(mysqli_error($mysqli));
$result = $mysqli->query("SELECT * FORM data") or die($mysqli->error);
?>
<div class="row justify-content-center">
<table class="table">
<thead>
<tr>
<th>usernames</th>
<th>Passowrds</th>
<th colspan="2">Action</th>
<tr>
</thead>
</div>
<?php while ($row = $result->fetch_assoc()): ?>
<tr>
<td><?php echo $row ['username'];?></td>
<td><?php echo $row ['password'];?></td>
<td>
<a href="index.php?edit=<?php echo $row ['id']; ?>"
class="btn btn-info">edit</a>
<a hraf="process.php?delete=<?php echo $row ['id']; ?>"
class="btn btn-danger">
</td>
</tr>
//this problem !
<?php endwhile; ?>
</table>
<?php
function pre_r( $arry ){
echo'<pre>';
print_r($array);
echo'</pre>';
}
?>
<div class="col-lg-6 m-auto">
<form action="process.php" method="post">
<input type="hidden" name="id" value=" <?php echo $id ?> "
<br><br><div class="card">
<div class="card-header bg-dark">
<h1 class="text-white text-center"> Insert Operation </h1>
</div><br>
<label> Username: </label>
<input type="text" name="username" class="form-control" value=" <?php echo $username; ?> " placeholder="Enter Your Username"> <br>
<label> Password: </label>
<input type="text" name="password" class="form-control" value=" <?php echo $password; ?> " placeholder="Password"> <br>
<?php
if ($update == true)
?>
<button class="btn btn-info" type="submit" name="update"> update </button>
<?php else: ?>
<button class="btn btn-success" type="submit" name="save"> Submit </button>
// and this problem !
<?php endif; ?>
</div>
</form>
</div>
</div>
</body>
</html>
code
process.php
=======================================================
<?php
session_start();
$mysqli = new mysqli('localhost', 'root', 'rootroot','crudcrud') or
die(mysqli_error($mysqli));
$id = 0;
$update = false;
$username = '';
$password = '';
if (isset ($_POST['save'])){
$usernames = $_POST['username'];
$passwords = $_POST['password'];
$mysqli->query("INSERT INTO data (username, password) VALUES('$username', '$password')") or
die($mysqli->error);
$_SESSION['message'] = "Record has been saved!";
$_SESSION['msg_type'] = "success!";
header('loocation: index.php');
}
if (isset ($_GET['delete'])){
$id = $_GET['delete'];
$mysqli->query("DELETE FROM data WHERE id=$id") or
die($mysqli->error());
SESSION['message'] = "Record has been deleted!";
SESSION['msg_type'] = "denger!";
header('loocation: index.php');
}
if (isset ($_GET['edit'])){
$id = $_GET['edit'];
$update = true;
$result = $mysqli->query("DELETE FROM data WHERE id=$id") or
die($mysqli->error());
if (count($result)==1){
$row = $result->fetch_array();
$username = $row['username'];
$password = $row['password'];
}
}
if (isset($_POST['update'])){
$id = $_POST['id'];
$username = $_POST['username'];
$password = $_POST['password'];
$mysqli->query("UPDATE data SET username='$username', password='$password' WHERE id=$id") or
die($mysqli->error);
$_SESSION['message'] = "Record has been Update!";
$_SESSION['msg_type'] = "warning!";
header('loocation: index.php');
}
This piece is completely wrong:
if(isset ($_SESSION['message']));?> //<-- : not ;
<div class="alert alert-<?=$_SESSION['msg_type']?>">
<?php
echo $_SESSION['message'];
unset($_SESSION['message']);
//<-- no closing tag
<?php endif ?> //<-- missing ;
Should be:
if(isset ($_SESSION['message'])):?>
<div class="alert alert-<?=$_SESSION['msg_type']?>">
<?php
echo $_SESSION['message'];
unset($_SESSION['message']);
endif; ?>
It get's pretty ugly when you use a lot of PHP and HTML in the same file, it might be time to look at using a template engine.

PHP MySQL - Simple database updater page [duplicate]

This question already has answers here:
Can I mix MySQL APIs in PHP?
(4 answers)
Reference - What does this error mean in PHP?
(38 answers)
What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such
(1 answer)
Closed 4 years ago.
Good morning everybody I've made this simple page that should update my database following some tutorials around the internet but still not updating the data when I press the submit button, can somebody help and correct the code ? I just need to update the ID from this table, I think this code can be helpful for many people out there... I'm going to paste the code below. Many thanks.
<?php
$servername = "localhost";
$username = "user";
$password = "pass";
$dbname = "database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$id_cus = $_GET["id_cus"];
$sql = "SELECT `id_customer`, `firstname`, `lastname`, `email` FROM `customer` WHERE `id_customer` = $id_cus";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$id = $row["id_customer"];
$nome = $row["firstname"];
$cognome = $row["lastname"];
$email = $row["email"];
}
} else {
echo "0 results";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="./panel.css">
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-12">
<main>
<form action="" method="post">
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Codice cliente</th>
<th class="col">Nome</th>
<th class="col">Cognome</th>
<th class="col">Indirizzo email</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" name="id" value="<?php echo $id ?>"/></td>
<td><?php echo $nome; ?></td>
<td><?php echo $cognome; ?></td>
<td><?php echo $email; ?></td>
</tr>
</tbody>
</table>
<input type="submit" name="submit" value="Aggiorna" class="pull-right">
</form>
</main>
</div>
</div>
</div>
</body>
</html>
<?php
// check if the form has been submitted. If it has, process the form and save it to the database
if (isset($_POST['submit']))
{
// confirm that the 'id' value is a valid integer before getting the form data
if (is_numeric($_POST['id']))
{
// get form data, making sure it is valid
$id = $_POST['id'];
// check that firstname/lastname fields are both filled in
if ($id == '')
{
// generate error message
echo 'ERROR: Please fill in all required fields!';
}
else
{
// save the data to the database
$conn->query("UPDATE customer SET id_customer='$id'")
or die(mysql_error());
// once saved, redirect back to the view page
header("Location: panel.php?id_cus=$id");
}
}
}
$conn->close();
?>
EDITED CODE TRYING ANOTHER SOLUTION bust still does not update why ? this should be very simple!
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
$databaseHost = 'localhost';
$databaseName = 'dbname';
$databaseUsername = 'dbuser';
$databasePassword = 'pass';
$mysqli = mysqli_connect($databaseHost, $databaseUsername, $databasePassword, $databaseName);
if(isset($_POST['update']))
{
$id = $_POST['id'];
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$email=$_POST['email'];
// checking empty fields
if(empty($fistname) || empty($lastname) || empty($email)) {
if(empty($firstname)) {
echo "<font color='red'>Name field is empty.</font><br/>";
}
if(empty($lastname)) {
echo "<font color='red'>lastname field is empty.</font><br/>";
}
if(empty($email)) {
echo "<font color='red'>Email field is empty.</font><br/>";
}
} else {
//updating the table
$result = mysqli_query($mysqli, "UPDATE customer SET firstname='$firstname',lastname='$lastname',email='$email' WHERE id_customer=$id");
//redirectig to the display page. In our case, it is index.php
header("Location: index.php");
}
}
?>
<?php
//getting id from url
$id = $_GET['id'];
//selecting data associated with this particular id
$result = mysqli_query($mysqli, "SELECT `id_customer`, `firstname`, `lastname`, `email` FROM `customer` WHERE `id_customer` = $id");
while($res = mysqli_fetch_array($result))
{
$firstname = $res['firstname'];
$lastname = $res['lastname'];
$email = $res['email'];
$id_customer = $res['id_customer'];
}
?>
<html>
<head>
<title>Edit Data</title>
</head>
<body>
Home
<br/><br/>
<form name="form1" method="post" action="panel.php">
<table border="0">
<tr>
<td>Name</td>
<td><input type="text" name="firstname" value="<?php echo $firstname;?>"></td>
</tr>
<tr>
<td>Lastname</td>
<td><input type="text" name="lastname" value="<?php echo $lastname;?>"></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email" value="<?php echo $email;?>"></td>
</tr>
<tr>
<td>ID</td>
<td><input type="text" name="id_customer" value="<?php echo $id_customer;?>"></td>
</tr>
<tr>
<td><input type="hidden" name="id" value=<?php echo $_GET['id'];?>></td>
<td><input type="submit" name="update" value="Update"></td>
</tr>
</table>
</form>
</body>
</html>
</html>

Undefined index: email in C:\Apache24\htdocs\checkup.php on line 10

i am new in php and i m creating a login system in my website every thing is working fine but 2 error are appearing in top of my website in every page,
Undefined index: email in C:\Apache24\htdocs\checkup.php on line 10
i have checked my mysql schema and coding but unable to find error please suggest me something to solve this error.
This is checkup.php page codding
<?php
include('dbconn.php');
if(!isset($_SESSION))
{
session_start();
}
$user_check= $_SESSION['email'];
$sql = mysqli_query($db,"SELECT fullname, email FROM register WHERE email='$user_check' ");
$row=mysqli_fetch_array($sql,MYSQLI_ASSOC);
$login_user = $row['email'];
$msguser = $row['fullname'];
?>
and this is login.php & loginconn.php page
<html>
<head>
<title>online shopping</title>
<?php
include 'header.php';
include 'dbconn.php';
include 'loginconn.php';
if ((isset($_SESSION['email']) != ''))
{
header('Location: index.php');
}
?>
<body>
<br>
<fieldset class="login_div">
<legend>User Login</legend>
<form method="POST" action="" >
<table border="0" cellspacing="10" >
<tr>
<td><?php echo $error; ?></td>
</tr>
<tr>
<td width="279"><center>            <label>Email:</label></td>
<td width="385"><input type="text" id="email" name="email" placeholder="email"></td>
</tr>
<tr>
<td><center>           <label>Password:</label></td>
<td><input type="password" name="password" placeholder="password"/></td>
</tr>
<tr>
<td colspan="2"><input class="loginbtn" type="submit" name="submit" value="Login" /></td>
</tr>
</table>
</form>
</fieldset>
</body>
</html>
<?php
include("dbconn.php");
$error = "";
if(isset($_POST["submit"]))
{
if(empty($_POST["email"]) || empty($_POST["password"]))
{
$error = "Both fields are required.";
}else
{
$email=$_POST['email'];
$password=$_POST['password'];
$email = stripslashes($email);
$password = stripslashes($password);
$email = mysqli_real_escape_string($db,$email);
$password = mysqli_real_escape_string($db,$password);
$password = md5($password);
$sql="SELECT id FROM register WHERE email='$_POST[$email]' and password='$_POST[$password]'";
$result= mysqli_query($db,$sql);
$row= mysqli_fetch_array($result, MYSQLI_ASSOC);
if( mysqli_num_rows($result) == 1)
{
$_SESSION['email'] = $email;
header("location: index.php");
}
else
{
$error = "Incorrect username or password.";
}
}
}
?>
you missed session_start() function call in file loginconn.php. Add the same code as in checkup.php:
if(!isset($_SESSION))
{
session_start();
}
How do you call checkup.php php page ?
Add the action: <form method="POST" action="checkup.php" > on your login page.
And test before any other test that the form has been submitted :
if(isset($_POST["submit"])) { // other tests }
More important, you've forgotten the session_start at the beginning of the page :
session_start();
This will maintain the session and the variables of it.

jQuery not receiving part of data

I'm creating testing application for sending and receiving messages using PHP/jQuery and AJAX. My code works with no problems when I comment out this part of code:
$("#sendUser").submit(function(){
return false;
});
If I leave this part uncommented then jQuery don't receive value from <select> tag. Can someone tell me how to solve this. This is my full code:
<form action="send_toUser.php" method="post" id="sendUser">
<label>Title: </label>
<input type="text" name="title" id="title"><br>
<label>To: </label>
<select name="user" id="user">
<?php $getData = $mysqli->query("select * from login");
while($row = $getData->fetch_assoc()):
?>
<option><?php echo $row['username']; ?></option>
<?php endwhile; ?>
</select><br>
<label>Message:</label><br>
<textarea name="content" id="content"></textarea><br>
<input type="submit" value="Send" id="sendToUserButton">
<label id="outputLabel" hidden></label>
</form>
send_toUser.php
<?php
session_start();
include 'functions.php';
protect();
$title = $_POST['title'];
$content = $_POST['content'];
$user = $_POST['user'];
$con = new mysqli("localhost", "root", "alen", "loginregister") or die($con->error);
$queryReceiver = $con->query("select * from login where username = '$user'");
$idReceiver = $queryReceiver->fetch_assoc();
$idReceiver = $idReceiver['user_id'];
$queryUser = $con->query("select * from admin where username='admin'");
$idUser = $queryUser->fetch_assoc();
$idUser = $idUser['id_admin'];
date_default_timezone_set('UTC');
$date = date('Y-m-d');
$con->query("insert into message values('', '$idReceiver', '$idUser', '$title', '$content','', '$date')") or die("Error while sending!");
echo "Message sent";
?>
script.js
$("#sendToUserButton").click(function(){
$.post("send_toUser.php"),
{"title" : ("#title").val(), "user" : ("#user").val(), "content" : ("#content").val()},
function(data){
$("#outputLabel").html(data);
}
});
$("#sendUser").submit(function(){
return false;
});

Categories