Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Registration page</title>
- <style type="text/css">
- body {
- font-family: Tahoma;
- font-size: 13px;
- background: #9999BB;
- }
- #container {
- border: 1px red solid;
- margin: 0px auto;
- width: 800px;
- }
- #head {
- border: 1px cyan solid;
- height: 100px;
- }
- #left {
- border: 1px blue solid;
- width: 196px;
- height: 200px;
- float: left;
- display: inline;
- }
- #main {
- border: 1px green solid;
- float: right;
- width: 600px;
- height: 400px;
- }
- #foot {
- border: 1px yellow solid;
- height: 40px;
- clear: both;
- }
- </style>
- </head>
- <body>
- <div id="container">
- <div id="head">
- This is a header
- </div>
- <div id="left">
- Some menuz
- </div>
- <div id="main">
- <!-- first page -->
- <div>
- <?php
- // function which makes the db connection
- function dbconnect($dbaddr = '127.0.0.1', $user = 'root', $pass = 'abc123') {
- $conn = mysql_connect($dbaddr, $user, $pass);
- if (!$conn) die("Couldn't connect to database!");
- else return $conn;
- }
- // function which executes the query
- function execquery($conn, $sql) {
- return mysql_query($sql, $conn);
- }
- if (count($_POST) > 0) { // if the $_POST array has values in it, it means it's come from your form.
- $name = $_POST['name'];
- $age = $_POST['name'];
- $gender = $_POST['gender'];
- $username = $_POST['username'];
- $password = md5($_POST['password']);
- if (count($_FILES) > 0) { // if $_FILES has values then there was an image upload
- $permpath = "images/uploads/". basename($_FILES['inputfile']['name']);
- if (move_uploaded_file($_FILES['inputfile']['tmp_name'], $permpath)) {
- echo "Image ". $_FILES['inputfile']['name'] ." uploaded successfully.";
- } else {
- echo "There was an error uploading your image.";
- $permpath = "";
- }
- }
- // db stuff starts here. first establish a db connection with dbconnect().
- $conn = dbconnect();
- // build the sql query
- $sql = "insert into users (name, age, gender, username, password, image) values (". $name .", ". $age .", ". $gender .", ". $username .", ". $password .", ". $permpath .";";
- // attempt to execute the query and print success/failure messages
- if (execquery($conn, $sql)) echo "User created successfully!";
- else echo "There was an error creating the user account; please try again.";
- } else {
- // if the $_POST array is empty then you know there was an error, or the request didn't come from your form
- echo "There was an error processing your registration. Please go back and try the FUCK again.";
- }
- ?>
- </div>
- </div>
- <div id="foot">
- This is a footer
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement