Есть такой код
if (isset($_POST['register'])) {
include 'database.php';
function CheckElement($data)
{
$data = trim($data);
$data = htmlspecialchars($data);
$data = stripcslashes($data);
$data = mysqli_real_escape_string ($conn , $data);
return $data;
}
$name = CheckElement($_POST['authname']);
$pass = CheckElement($_POST['authpassword']);
$passagain = CheckElement($_POST['authpasswordagain']);
$email = CheckElement($_POST['authemail']);
$sql = "INSERT INTO users (user_name , user_password , user_password2 , user_email) VALUES
('".$name."' , '".$pass."' , '".$passagain."' , '".$email."' )";
$query = mysqli_query($conn , $sql);
if ($query) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
?>
<form action="<?php print htmlspecialchars($_SERVER['PHP_SELF']);?>" class="form" method="POST" onsubmit="return CheckFunction()" name="register">
<label for="auth">Name</label>
<input type="text" name="authname" placeholder="Enter Name" id="auth"><span id="errorname"></span>
<label for="auth">Password</label>
<input type="password" name="authpassword" placeholder="Enter Password" id="auth"><span id="errorpass"></span>
<label for="auth">Password</label>
<input type="password" name="authpasswordagain" placeholder="Enter Password Again" id="auth"><span id="errorpass2"></span>
<label for="auth">Email</label>
<input type="email" name="authemail" placeholder="Enter Email" id="auth"><span id="erroremail"></span>
<button type="submit">Button</button>
</form>
Не добавляются данные в таблицу. Помогите разобратся.Заранне Спасибо
вопрос решился вот таким образом
if (isset($_POST['register'])) {
include 'database.php';
function CheckElement($data)
{
$data = trim($data);
$data = htmlspecialchars($data);
$data = stripcslashes($data);
return $data;
}
$name = mysqli_real_escape_string($conn ,CheckElement($_POST['authname']));
$pass = mysqli_real_escape_string($conn ,CheckElement($_POST['authpassword']));
$passagain = mysqli_real_escape_string($conn , CheckElement($_POST['authpasswordagain']));
$email = mysqli_real_escape_string($conn , CheckElement($_POST['authemail']));
$sql = "INSERT INTO users (user_name , user_password , user_password2 , user_email) VALUES
('".$name."' , '".$pass."' , '".$passagain."' , '".$email."' )";
$query = mysqli_query($conn , $sql);
if ($query) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
?>
<form action="<?php print htmlspecialchars($_SERVER['PHP_SELF']);?>" class="form" method="POST" onsubmit="return CheckFunction()">
<label for="auth">Name</label>
<input type="text" name="authname" placeholder="Enter Name" id="auth"><span id="errorname"></span>
<label for="auth">Password</label>
<input type="password" name="authpassword" placeholder="Enter Password" id="auth"><span id="errorpass"></span>
<label for="auth">Password</label>
<input type="password" name="authpasswordagain" placeholder="Enter Password Again" id="auth"><span id="errorpass2"></span>
<label for="auth">Email</label>
<input type="email" name="authemail" placeholder="Enter Email" id="auth"><span id="erroremail"></span>
<button type="submit" name="register">Button</button>
</form>
Спасибо всем за совет
Есть строка вида ID1==Vasya==200==URL1|ID2==Petya==100==URL2|ID3==Sergey==300==URL3| и тд
Что быстрее json_decode или explode? Информация хранится в виде 1,2,3 есть возможность изменить на [1,2,3] В дальнейшем требуется из этих данных получить...