So here is my scripts:
my Ajax:
$('#ether-wallet').submit(function (e) {
e.preventDefault();
var name = $('#etherwallet').val();
var dataString = 'name=' + name;
$.ajax({
type: 'POST',
data: dataString,
url: 'Database/wallet.inc.php',
success: function (data) {
alert(data);
}
});
});
and I am trying to submit the form without leaving the page, Here is my PHP:
<form id="ether-wallet" class="wallet-form" method="POST">
<span class="span">Ether Wallet: </span>
<input type="text" name="etherwallet" placeholder="Press to lock" id="etherwallet" class="inputapi" value=""/>
<button id="etherlock" class="lockbutton" type="submit" name="etherlock">Lock</button>
</form>
and here's where I want to send the data
all of this is inside the php
session_start();
if(isset($_POST['ether-wallet'])) {
include_once 'dhb.inc.php';
$etherwallet = mysqli_real_escape_string($conn, $_POST['name']);
$idbridge1 = mysqli_real_escape_string($conn, $_SESSION['u_id']);
if (empty($etherwallet)) {
header("Location: ../signup.php?signup=success1");
exit();
} else {
if (strlen($etherwallet) != 42 ) {
header("Location: ../signup.php?signup=success2");
exit();
} else {
$sql = "UPDATE users SET eth_wallet = '$etherwallet' WHERE user_id = '$idbridge1'";
mysqli_query($conn, $sql);
header("Location: ../signup.php?signup=success3");
exit();
}
}
}
Thanks for the help boys!!