Thread titleFromLast replied
Now searching...
Neoseeker Forums » » Web Coding » please who can help to edit this form processors » Post Reply

Note to Guests: For the enjoyment of other visitors, and to help keep this forum tidy and working smoothly, please make sure you search the forum before posting your question.
REPLY TO A THREAD
Name:* Members, please LOGIN before posting
Email: We use this to display your Gravatar

Sign in with
Subject:*
Message:*


HTML is not allowed
markup is allowed

Help with markup tags

Enabling Buttons in IE7




Smilies:
  ·all smilies here
:) :P ;) :( :| ;( :D :confused: :cool: :# :o ^_^ :colored: :thick:

Thread Recap (last 10 posts from newest to oldest)

Jul 08, 12 at 2:27am
BeZ


You'd put if before you insert the data into the database

//This is the directory where images will be saved 
$target = "images/"; 
$target = $target . basename( $_FILES['photo']['name']); 

//This gets all the other information from the form 
$id=mysql_real_escape_string($_POST['id']); 
$username=mysql_real_escape_string($_POST['username']); 
$password=mysql_real_escape_string($_POST['password']); 
$surname=mysql_real_escape_string($_POST['surname']); 
$othername=mysql_real_escape_string($_POST['othername']); 
$gender=mysql_real_escape_string($_POST['gender']); 
$level=mysql_real_escape_string($_POST['level']); 
$bornday=mysql_real_escape_string($_POST['bornday']); 
$bornmonth=mysql_real_escape_string($_POST['bornmonth']); 
$bornyear=mysql_real_escape_string($_POST['bornyear']); 
$state=mysql_real_escape_string($_POST['state']); 
$localgovt=mysql_real_escape_string($_POST['localgovt']);
$religion=mysql_real_escape_string($_POST['religion']); 
$email=mysql_real_escape_string($_POST['email']); 
$phoneno=mysql_real_escape_string($_POST['phoneno']); 
$hosteltype=mysql_real_escape_string($_POST['hosteltype']); 
$hostelno=mysql_real_escape_string($_POST['hostelno']);
$address=mysql_real_escape_string($_POST['address']);
$pic="images/".($_FILES['photo']['name']); 

// Connects to your Database 
mysql_connect("localhost", "******", "*******") or die(mysql_error()) ; 
mysql_select_db("*******") or die(mysql_error()) ; 

//check username isn't taken
$query = mysql_query("SELECT id FROM users WHERE username = '$username'");
if(mysql_num_rows($query) > 0) {
  //if it is echo error
  echo "Username taken";
} else {

  //Writes the information to the database 
  mysql_query("INSERT INTO `*********` VALUES ('$pic', '$id', '$username', '$password', '$surname', '$othername', '$gender', '$level', '$bornday', '$bornmonth', '$bornyear', '$state', '$localgovt', '$religion', '$email', '$phoneno', '$hosteltype', '$hostelno', '$address')") ; 


  //Writes the photo to the server
  if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 
  { 


    //Tells you if its all ok 
    echo "Congratulation!

    Your registration is successful...
    You can now login to your NIMELSSA student login portal</font>"; 
  } 
  else { 

    //Gives and error if its not 
    echo "Sorry, your registration fail.
    You need to attached your passport"; 
  }
}




Jul 08, 12 at 12:20am
Alao


thank you so much for your reply.
but pls, where wil i paste dat mysql query code within my initial form processor.
i mean the code for that username



Jul 07, 12 at 1:38pm
BeZ


To get the form to go to a different page you need to add an action to the form, the action is the page that all the post data is sent to (if an action isn't supplied then the page the form is on will be the one that gets the data), so do this

<form action='regsuccess.php' method='post' enctype='multipart/form-data'>
<!-- input fields -->
</form>


To test if someone already has the same username try to select the username from the database, if you get a result then say the username's already taken

$query = mysql_query("SELECT id FROM users WHERE username = '$username'");

if(mysql_num_rows($query) > 0) {
  echo "That username is taken";
} else {
  //carry on validating other inputs and insert into database
}


You should also use mysql_real_escape_string() on all your inputs to stop users from doing any sql injection.



Jul 07, 12 at 10:58am
alao


please who can help me out!

1 - i want my registration form to redirect my user to a separate page known as 'regsuccess.php' after the registration form has been submitted instead of it to say congratulation! your registration is successful.

2- secondly i want the field 'username' to be unique; that is if someone want to use the same username which someone else has been used, it should notify such user that the username has been taken.that means no two user can use the same username.
please help me becos am stuck.

i believe people are good php coder here.
thank you all! as am expecting your response.
see my code below:

<?php

//This is the directory where images will be saved
$target = "images/";
$target = $target . basename( $_FILES['photo']['name']);

//This gets all the other information from the form
$id=$_POST['id'];
$username=$_POST['username'];
$password=$_POST['password'];
$surname=$_POST['surname'];
$othername=$_POST['othername'];
$gender=$_POST['gender'];
$level=$_POST['level'];
$bornday=$_POST['bornday'];
$bornmonth=$_POST['bornmonth'];
$bornyear=$_POST['bornyear'];
$state=$_POST['state'];
$localgovt=$_POST['localgovt'];
$religion=$_POST['religion'];
$email=$_POST['email'];
$phoneno=$_POST['phoneno'];
$hosteltype=$_POST['hosteltype'];
$hostelno=$_POST['hostelno'];
$address=$_POST['address'];
$pic="images/".($_FILES['photo']['name']);

// Connects to your Database
mysql_connect("localhost", "******", "*******") or die(mysql_error()) ;
mysql_select_db("*******") or die(mysql_error()) ;

//Writes the information to the database
mysql_query("INSERT INTO `*********` VALUES ('$pic', '$id', '$username', '$password', '$surname', '$othername', '$gender', '$level', '$bornday', '$bornmonth', '$bornyear', '$state', '$localgovt', '$religion', '$email', '$phoneno', '$hosteltype', '$hostelno', '$address')") ;


//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{


//Tells you if its all ok
echo "Congratulation!

Your registration is successful...
You can now login to your NIMELSSA student login portal</font>";
}
else {

//Gives and error if its not
echo "Sorry, your registration fail.
You need to attached your passport";
}
?>




Powered by neoforums v2.2.0c (toro)
Copyright Neo Era Media, Inc. 1999-2014

Neoseeker.com   |   Forum Rules   |   Forum FAQ   |   Neoseeker Terms of Use   |   Supermods On Duty [ server id: web6 ··· elapsed: 0.0800]
Chat and Lounges
Game Platforms
Mobile Platforms