Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to use $_REQUEST for inserting data in a mysql database?
    primarykey
    data
    text
    <p>I already have this code figured out, but the entries a user submits with the submit button aren't going anywhere. Is there any way to fix this, or should I just use the $_POST method? </p> <p>PHP code:</p> <pre><code> &lt;?php include ("dbroutine.php"); function register() { $connect = db_connect; if (!$connect) { die(mysql_error()); } $select_db = mysql_select_db(securitzed, $connect); if (!$select_db) { die(mysql_error()); } //Collecting info $fname = $_REQUEST ['fname']; $lname = $_REQUEST ['lname']; $username = $_REQUEST['username']; $password = $_REQUEST['password']; $email = $_REQUEST['email']; //Here we will check do we have all inputs filled if(empty($_REQUEST['username'])){ die("Please enter your username!&lt;br&gt;"); } if(empty($_REQUEST['password'])){ die("Please enter your password!&lt;br&gt;"); } if(empty($_REQUEST['email'])){ die("Please enter your email!"); } //Let's check if this username is already in use $user_check = mysql_query("SELECT username FROM members WHERE username = '".$_REQUEST ['username']."'"); $do_user_check = mysql_num_rows($user_check); //Now if email is already in use $email_check = mysql_query("SELECT email FROM members WHERE email= '".$_REQUEST['email']."'"); $do_email_check = mysql_num_rows($email_check); //Now display errors if($do_user_check &gt; 0){ die("Username is already in use!&lt;br&gt;"); } if($do_email_check &gt; 0){ die("Email is already in use!"); } //If everything is okay let's register this user $insert = mysql_query("INSERT INTO members (username, password, email) VALUES ('".$_REQUEST['username']."', '".$_REQUEST['password']."', '".$_REQUEST['email']."', '".$_REQUEST['fname']."', '".$_REQUEST['lname']."')"); if(!$insert){ die("There's little problem: ".mysql_error()); } } switch($act){ case "register"; register(); break; } </code></pre> <p>HTML code:</p> <pre><code> &lt;body&gt; &lt;form method="post"&gt; First Name: &lt;input type="text" name="fname" value="" /&gt; &lt;br /&gt; Last Name: &lt;input type="text" name="lname" value="" /&gt; &lt;br /&gt; E-mail: &lt;input type="email" name="email" value="" /&gt; &lt;br /&gt; Desired Username: &lt;input type="text" name="username" value="" /&gt; &lt;br /&gt; Password: &lt;input type="password" name="password" value="" /&gt; &lt;br /&gt; Confirm Password: &lt;input type="password" name="passwordconf" value="" /&gt; &lt;br /&gt; &lt;input type="submit" value="Submit"/&gt; &lt;/form&gt; &lt;/body&gt; </code></pre> <p>If I need to add anything, could anyone point it out, if not, I could also add some extra code if needed.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload