When I call the index.js it doesn't work in my webhost server and the cdn too but works perfectly on my Local xampp server .
<?php
/* Main page with two forms: sign up and log in */
require 'db.php';
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Sign-Up/Login Form</title>
<?php include 'css/css.html'; ?>
</head>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (isset($_POST['login'])) { //user logging in
require 'login.php';
}
elseif (isset($_POST['register'])) { //user registering
require 'register.php';
}
}
?>
<body>
<div class="form">
<ul class="tab-group">
<li class="tab"><a href="#signup">Sign Up</a></li>
<li class="tab active"><a href="#login">Log in</a></li>
</ul>
<div class="tab-content">
<div id="login">
<h1>Welcome to </h1>
<form action="index.php" method="post" autocomplete="off">
<div class="field-wrap">
<label>
Email Address<span class="req">*</span>
</label>
<input type="email" required autocomplete="off"
name="email"/>
</div>
<div class="field-wrap">
<label>
Password<span class="req">*</span>
</label>
<input type="password" required autocomplete="off"
name="password"/>
</div>
<p class="forgot"><a href="forgot.php">Forgot Password?</a></p>
<button class="button button-block" name="login" />Log
In</button>
</form>
</div>
<div id="signup">
<h1>Sign Up for Free</h1>
<form action="index.php" method="post" id="form1"
autocomplete="off">
<div class="top-row">
<div class="field-wrap">
<label>
First Name<span class="req">*</span>
</label>
<input type="text" required autocomplete="off"
name='firstname' id="txtNumeric" />
</div>
<div class="field-wrap">
<label>
Last Name<span class="req">*</span>
</label>
<input type="text"required autocomplete="off"
name='lastname'
id="txtNumeric" />
</div>
</div>
<div class="field-wrap">
<label>
Contact number<span class="req">*</span>
</label>
<input type="number"required autocomplete="off"
name='contact'
onclick="return AllowSingleSpaceNotInFirstAndLast();" />
</div>
<div class="field-wrap">
<label>
Email Address<span class="req">*</span>
</label>
<input type="email"required autocomplete="off" name='email'
onclick="return AllowSingleSpaceNotInFirstAndLast();" />
</div>
<div class="field-wrap">
<label>
Set A Password<span class="req">*</span>
</label>
<input type="password"required autocomplete="off"
name='password'/>
</div>
<button type="submit" class="button button-block"
name="register"
onclick="return validates()" />Register</button>
</form>
</div>
</div><!-- tab-content -->
</div> <!-- /form -->
<script
src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'>
</script>
<script src="js/index.js"></script>
<script type="text/javascript">
function validates(){
$(function() {
$('#txtNumeric').keydown(function (e) {
if (e.shiftKey || e.ctrlKey || e.altKey) {
e.preventDefault();
} else {
var key = e.keyCode;
if (!((key == 8) || (key == 32) || (key == 46) || (key >= 35 && key
<=
40) || (key >= 65 && key <= 90))) {
e.preventDefault();
}
}
});
});
function AllowSingleSpaceNotInFirstAndLast() {
var obj = document.getElementById('TextBox1');
obj.value = obj.value.replace(/^\s+|\s+$/g, "");
var CharArray = obj.value.split(" ");
if (CharArray.length > 2) {
alert("User name NOT VALID");
return false;
}[enter image description here][1]
else {
alert("User name VALID");
}
return true;
}
}
</script>
</body>
</html>
The problem here is I cannot run the code properly in my webhost. My code works fine on local xampp server. I also edited the DB user, DB name etc but it doesn't help. can anyone help me ?
Thank you!
PS. I am new to stackoverflow. sorry for my bad formatting
I think problem is in your path of files you should check your path of file or may be you had not uploaded your all files with proper code on server.
Replace this code
<script src="js/index.js"></script>
To
<script src="<?php echo $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>/js/index.js"></script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.