Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <a href="index.php">Index</a><br>
- <form name="registrationForm" method="post" onsubmit="return validateForm()">
- <input type="text" class="form-control" placeholder="Enter username" name="username"><font color="red">*</font>
- <input type="text" class="form-control" placeholder="Enter email address" name="email"><font color="red">*</font>
- <input type="password" class="form-control" placeholder="Enter password" name="password"><font color="red">*</font>
- <input type="text" class="form-control" placeholder="Enter first name" name="first"><font color="red">*</font>
- <input type="text" class="form-control" placeholder="Enter last name" name="last"><font color="red">*</font>
- <input type="text" class="form-control" placeholder="Enter zip code" name="zip"><font color="red">*</font>
- <input class="btn btn-default" type="submit" name="submit" value="Submit">
- </form>
- <?php
- ini_set('display_errors',1);
- error_reporting(E_ALL);
- if (isset($_POST['submit'])){
- //if($_SERVER["REQUEST_METHOD"] == "POST"){
- $username = $_POST["username"];
- $email = $_POST["email"];
- $password = $_POST["password"];
- $first = $_POST["first"];
- $last = $_POST["last"];
- $zip = $_POST["zip"];
- // Check connection
- if ($db->connect_error) {
- die("Connection failed: ".$db->connect_error);
- }
- //flag to detect if the username exists in db
- $flag = 0;
- $sql = "SELECT username FROM users WHERE username = '".$username."';";
- $result = $db->query($sql);
- if ($result->num_rows > 0) {
- $flag = 1;
- }
- //If the username already exists then alert the user, else insert the record to the db and send user to login.php
- if ($flag == 1){
- echo "<script>alert("Sorry, that username is already taken. Please choose another.");</script>";
- }
- else {
- $sql = "INSERT INTO users (first, last, username, email, password, zip) VALUES ('".$first."', '".$last."', '".$username."', '".$email."', '".$password."', '".$zip."')";
- if ($db->query($sql) === TRUE) {
- //echo "Registration successful";
- //$filename = "/profiles/".$username.".php";
- //chmod($filename,0777);
- echo 'Current script owner: ' . get_current_user() . "<br>";
- echo 'posix: '.posix_getuid()."<br>";
- echo getcwd()."<br>";
- $last_line = system('whoami', $retval);
- echo $last_line . " " . $retval;
- $file = fopen("profiles/test.txt", "w") or die("Unable to open file!");
- //$txt = "This is a user profile for ".$username;
- //fwrite($file, $txt);
- fclose($file);
- //header('Location: login.php');
- } else {
- echo "Registration error, please try again later.";
- }
- }
- }
- $db->close();
- ?>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement