Click here to Skip to main content
15,868,037 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I made a sign in sheet but whenever I press signup It goes to this link

{"code":"MethodNotAllowedError","message":"POST is not allowed"}

I'm using Dreamweaver 2017

here is my code

//Doc name signup.php
PHP
<?php
	include_once 'Header.php';
?>
		
								
		<section class="main-container">
			<div class="main-wrapper">
			  <h2> Signup </h2>
			  
				

					
					
					Sign up 
					 
				
			</div>
			
			
			
		</section>
	
<?php
	include_once 'footer.php';
?> 

//signup.inc.php
PHP
<?php

if (isset($_POST['submit'])) {
	
	include_once 'dbh.inc.php';
	
	$first = mysqli_real_escape_string($conn, $_POST['first']);
	$last = mysqli_real_escape_string($conn, $_POST['last']);
	$email = mysqli_real_escape_string($conn, $_POST['email']);
	$uid = mysqli_real_escape_string($conn, $_POST['uid']);
	$pwd = mysqli_real_escape_string($conn, $_POST['pwd']);
	
	 {
	header("Location: ../signup.php?signup=empty");
	exit();
	
	//Error hsndlers
	//Chack for empty fields
	if (empty($first) || empty($last)|| empty($email)|| empty($uid)|| empty($pwd)) {
		exit();
	} else {
		//Check if input charecters are valid
		if (!preg_match("/^[a-zA-Z]*$/", $first) || !preg_match("/^[a-zA-Z]*$/", $last) ) {
			
			
				header("Location: ../signup.php?signup=invalid");
				exit();
		} else {
			
			 //Check if email is valid
			
			if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
				header("Location: ../signup.php?signup=invalidemail");
				exit();
				
			} else {
				$sql = "SELECT * FROM users WHERE user_uid='$uid'";
				$result = mysql_query($conn, $sql);
				$resultCheck + mysqli_num_rows($result);
				
				if ($resultCheck > 0) {
					header("Location: ../signup.php?signup=usertaken");
					exit();
					
				
				}else{
					//hashing password
					$hashedPwd = password_hash($pwd, PASSWORD_DEFAULT);
					//Insert the user to database
				
					$sql = "INSERT INTO users (user_first, user_last,user_email, user,pwd) VALUES ('$first', '$last', '$email', '$uid' '$hashedPwd');";
				
					mysqli_query($conn, $sql);
					header("Location: ../signup.php?signup=success");
					exit();
					
		}
	}
	
}
	
} else {
	header("Location: ../signup.php");
	exit();

}

//dbh.inc.php
PHP
<?php

$dbServername = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbName = "servername_loginsystem";

$conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);


What I have tried:

I've checked for syntax errors, renaming server, installing XAMPP(I think I did it properly). FYI i'm new to php so it might be something simple.
Posted
Updated 23-Apr-18 4:42am
v2

1 solution

The error source is most probably located in the form tag which you have not shown or in the Apache configuration.

Such errors occur when the action attribute of the form tag point to a HTML file instead of a script file.

They may also occur when the web server is not (properly) configured for script execution (PHP in your case).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900