Skip to content

Commit

Permalink
Fix full phone
Browse files Browse the repository at this point in the history
  • Loading branch information
raja-muhammad-asher committed Apr 3, 2024
1 parent 2f9e59e commit 3ade443
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 61 deletions.
2 changes: 1 addition & 1 deletion public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
</div>
<div class="field">
<div class="control">
<input class="input" type="tel" id="phone" name="phone[full]" placeholder="Phone" required>
<input class="input" type="tel" id="phone" name="phone" placeholder="Phone" required>
</div>
</div>
<span id="error-msg" class="help is-danger"></span>
Expand Down
121 changes: 61 additions & 60 deletions public/verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
if (!isset($_POST['verify'])) {
$_SESSION["name"] = $_POST['name'];
$_SESSION["email"] = $_POST['email'];
$phone = $_POST['phone']['full'];
$phone = $_POST['full_phone'];

$phone = (int)str_replace("+", "", $phone);
$_SESSION["phone"] = $phone;

Expand Down Expand Up @@ -90,80 +91,80 @@
<html>

<head>
<meta charset="utf-8">
<title>
<?php echo htmlspecialchars($business_name); ?> WiFi</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<link rel="stylesheet" href="assets/styles/bulma.min.css"/>
<link rel="stylesheet" href="vendor/fortawesome/font-awesome/css/all.css"/>
<link rel="icon" type="image/png" href="assets/images/favicomatic/favicon-32x32.png" sizes="32x32"/>
<link rel="icon" type="image/png" href="assets/images/favicomatic/favicon-16x16.png" sizes="16x16"/>
<link rel="stylesheet" href="assets/styles/style.css"/>
<meta charset="utf-8">
<title>
<?php echo htmlspecialchars($business_name); ?> WiFi</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="assets/styles/bulma.min.css" />
<link rel="stylesheet" href="vendor/fortawesome/font-awesome/css/all.css" />
<link rel="icon" type="image/png" href="assets/images/favicomatic/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="assets/images/favicomatic/favicon-16x16.png" sizes="16x16" />
<link rel="stylesheet" href="assets/styles/style.css" />
<?php
if ($otp_error) { ?>
<meta http-equiv="refresh" content="2;url=index.php"/>
<meta http-equiv="refresh" content="2;url=index.php" />
<?php } ?>
</head>

<body>
<div class="page">
<div class="page">

<div class="head">
<br>
<figure id="logo">
<img src="assets/images/logo.png">
</figure>
<br>
<figure id="logo">
<img src="assets/images/logo.png">
</figure>
</div>

<div class="main">
<section class="section">
<div class="container">
<?php
if ($otp_error) { ?>
<p class="content has-text-centered" style="color: red;">
Sorry, the OTP you entered is not correct. Please try again.
</p>
<?php
} else { ?>
<div id="contact_form" class="content has-text-centered">
Please enter the <?php echo $digits; ?> digit code received on your provided phone number
</div>
<br>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return codeCheck()">
<div class="field">
<div class="control has-icons-left">
<input class="input" type="number" name="code" id="code" placeholder="Code" required>
<span class="icon is-small is-left">
<i class="fas fa-comment"></i>
</span>
</div>
</div>
<p class="help is-danger" id="codeError" style="display: none; margin-bottom: 10px;">
Code Invalid: not a <?php echo $digits; ?> digit number
</p>
<div class="buttons is-centered">
<input class="button is-link" type="submit" name="verify" value="Verify">
</div>
</form>
<?php
} ?>
<section class="section">
<div class="container">
<?php
if ($otp_error) { ?>
<p class="content has-text-centered" style="color: red;">
Sorry, the OTP you entered is not correct. Please try again.
</p>
<?php
} else { ?>
<div id="contact_form" class="content has-text-centered">
Please enter the <?php echo $digits; ?> digit code received on your provided phone number
</div>
</section>
<br>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return codeCheck()">
<div class="field">
<div class="control has-icons-left">
<input class="input" type="number" name="code" id="code" placeholder="Code" required>
<span class="icon is-small is-left">
<i class="fas fa-comment"></i>
</span>
</div>
</div>
<p class="help is-danger" id="codeError" style="display: none; margin-bottom: 10px;">
Code Invalid: not a <?php echo $digits; ?> digit number
</p>
<div class="buttons is-centered">
<input class="button is-link" type="submit" name="verify" value="Verify">
</div>
</form>
<?php
} ?>
</div>
</section>
</div>
</div>
<script>
</div>
<script>
function codeCheck() {
var codeInput = document.getElementById('code').value;

//Checking the number of digits:
if (codeInput.length != <?php echo htmlspecialchars($digits); ?> || isNaN(codeInput)) {
document.getElementById("codeError").style.display = "block";
return false;
} else {
return true;
}
var codeInput = document.getElementById('code').value;

//Checking the number of digits:
if (codeInput.length != <?php echo htmlspecialchars($digits); ?> || isNaN(codeInput)) {
document.getElementById("codeError").style.display = "block";
return false;
} else {
return true;
}
}
</script>
</script>
</body>

</html>

0 comments on commit 3ade443

Please sign in to comment.