I am currently using jquery and ofc php to post to a database. However, i dont know what im doing wrong.
here is my html:
here is my Jquery:HTML Code:<div id="output"><input type="text" id="username" /><span class="info"></span></div> <div id="check"></div> <div id="button">Register</div>
And here is my php:Code:$(document).on("click", "#button", function(){ var info = $('#username').val(); $.ajax({ type: 'POST', url: 'save.php', data: {username:info}, //dataType: 'html', success: function(){ alert(info); } }); });
I am able to grab the information from the database i am just not able to upload the information to the database. Does anyone know my problem?PHP Code:$server = $_SERVER['HTTP_HOST'];
$user = "root";
$pass = "";
$db = "landr";
$table = "reg";
$con = mysqli_connect($server,$user,$pass, $db) or die('Failed to connect!');
$name = $_POST['username'];
if(mysql_query("INSERT INTO $table VALUES('$name')"))
echo "Successfully Inserted";
else
echo "Insertion Failed";
Thanks



Reply With Quote



Bookmarks