I am new on sitepoint I have issue that under function is not working and never insert data into database even I tried to other basic insert code too but it also not worked. Code also not shows any error . I am using php version 7.0(inherited)
I just shifted in a new hosting company where my previous cPanel every thing was good. Let consider if anything mistake in my code then why when I use basic very simple insert code then. It not work? I thought there is mistake in my database version or some setting I left to do.
Please view my phpinfo();
: : https://bit.ly/2M6Wu3R (PHP Info)
Error page: https://bit.ly/2LEcRZs (Registration Page)
Config file: https://bit.ly/2M37gbm (direct access not allowed)
I have been pasted by PHP sir, if you want check my code. Or run in your local host if you register same email 2 times and show error then thing code is now right. Current it not show and continuing show success message but not save into database.
where is my mistake how I fix this issue please help.
ini_set('session.use_strict_mode',1);
session_start();
session_regenerate_id(true);
$msg = "" ;
error_reporting(E_ALL);
ini_set("display_errors", 1);
use PHPMailer\PHPmailer\PHPMailer;
$rand=rand();
$_SESSION['rand']=$rand;
if (isset($_POST['submit']) ) {
include ('../authConfig.php');
$name = $con->real_escape_string(htmlspecialchars(ucwords(strtolower($_POST['name']))));
$email = $con->real_escape_string(htmlspecialchars(strtolower($_POST['email'])));
$extra="regiNew_type=userEmail=confirmed-stg=2.php";
$host=$_SERVER['HTTP_HOST'];
$uri=rtrim(dirname($_SERVER['PHP_SELF']),'/\\');
$uip=$_SERVER['REMOTE_ADDR'];
$agent = $_SERVER['HTTP_USER_AGENT'];
$crn = 'CRN';
$characters = array_merge(range('0','9'));
for ($i = 0; $i < 7; $i++) {
$rand = mt_rand(0, count($characters)-1);
$crn .= $characters[$rand];
}
$req = 'REQ';
$characters = array_merge(range('A','Z'), range('0','9'));
for ($i = 0; $i < 9; $i++) {
$rand = mt_rand(0, count($characters)-1);
$req .= $characters[$rand];
}
if ($name == "" || $email == "" )
$msg = "<div id='myTostwarning'>All fields is required to go ahead.</div>";
else {
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$msg= "<div id='myTostwarning'>Invalid formate of your email, re-enter valid email address</div>"; }else{
$sql = $con->query("SELECT * FROM UserLogin WHERE Email_ID='$email'");
if ($sql->num_rows > 0) {
$msg = "<div id='myTosterror'>Email already exist in our records</div>";
} else {
$token = 'qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM0123456789!$/()*';
$token = str_shuffle($token);
$token = substr($token, 0,70);
$con->query("INSERT INTO UserLogin (CustID,ReqID,Name,Email_ID,Protocol,System,isEmailConfirmed,Emailtoken,EmailtokenExpire) VALUES('$crn','$req','$name','$email','$uip','$agent','PENDING','$token',DATE_ADD(NOW(), INTERVAL 30 MINUTE));");
require_once "PHPMailer/PHPMailer.php";
require_once "PHPMailer/Exception.php";
$mail = new PHPMailer();
$mail->addAddress($email);
$mail->setFrom("noreply@example.com", "Verify Your Email");
$mail->Subject = "Please confirm email to complete your registration";
$mail->isHTML(true);
$mail->Body = "Hello $name thank you for registration";
$mail->AltBody = "Please verify your email to we can proceed to create your account and move you to next step.<br>Copyright © content at all texts or images, logo, designs attached in this mail. ";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
if ($mail->send())
{
$_SESSION['successmsg']="You have been registered successfully! Please verify your email to create password";
header('Location: ../index.php');
exit(); }
else {
$_SESSION['errormsg']="Something wrong happened! Please try again..";
header('Location: ../index.php');
exit();
}
}
}
}
}