Insert or Update data securely using Json php webservices
Dear Guys I have created this video because I had got a comment on my before video on how to insert data securely using the Json webservices ...This is a frequently asked question so that is the reason why I have created this video..
In this video I have shown you the most important steps to set this type of code it should be really easy..
Below are the code for the most important files
register.php
<?php header('Access-Control-Allow-Origin: *'); ?>
<?php header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept'); ?>
<?php header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT'); ?>
<?php
include_once('confi.php');
error_reporting(E_ALL);
//Get the variables here
$username = isset($_POST['username']) ? mysql_real_escape_string($_POST['username']) : "";
$email = isset($_POST['email']) ? mysql_real_escape_string($_POST['email']) : "";
$password = isset($_POST['password']) ? mysql_real_escape_string($_POST['password']) : "";
//Get the variables here end/update statement
$insertstatement = 'INSERT INTO `mytesttable`(`id`,`username`,`email`,`password`) VAlUES (NULL,"'.$username.'","'.$email.'","'.$password.'")';
$query123 = mysql_query($insertstatement) or trigger_error(mysql_error()." ".$insertstatement);
//echo "$query123";
//Registration code here (insert statements)
if($query123 == 1){
$result[] = array("status" => 1);
}else{
$result[] = array("status" => 0);
}
/* Output header */
header('Content-type: application/json');
echo json_encode($result);
?>
Post in the javascript that was in login.htm
$.post("http://localhost/loginangulartutorial/webservices/register.php",
{
password: confirmpassword,
email: email,
username: username
},
function(data, status){
alert("Data: " + data + "\nStatus: " + status);
var status = data[0].status;
if(status == 1){
alert('inserted /updated sucessfully');
}
if(status == 0){
alert('failure statement');
}
});
I hope that this tutorial was helpful comment below my video in case you have doubts or questions..
Subscribe to my channel http://www.youtube.com/subscription_center?add_user=joeljfernandes
.png)

Could you possibly send me an email? I have a question please? Kayndaydaddy@gmail.com
ReplyDelete
ReplyDeleteThank you very much that you shared your experiences, video came out very good and informative. The main thing is that everything is clear and it is really really save my time!
Richard Brown virtual data room pricing