0

I found a lot of these on the side but I don't understand them. Can someone just post the good code and point the wrong things out.

Code didn't want to be posted here is a foto of it

html form enter image description here

php action enter image description here

If it helps iam using byethost so I could be something byethost related

waki
  • 1,248
  • 2
  • 17
  • 27

2 Answers2

0

Your post indexing is wrong. You can not use value of id attrbute with POST. You have to use value of name attribute so change your code to

$_POST['firstname'] AND $_POST['lastname']
DD77
  • 776
  • 2
  • 8
  • 25
0

A few things: 1. form should be specified method.

<div> 
  <form action="login_action.php" method="post" >
  <label for="fname">First Name</label>
  <input type="text" id="fname" name="firstname" >

  <label for="lname">Last Name</label>
  <input type="text" id="lname" name="lastname" >
</div>

otherwise, the form will be using get method, and there is no data send to $_POST. refer to http://www.w3schools.com/tags/att_form_method.asp

As @User7 mentioned. The data index in $_POST is based on the input name, not id

 $sql ='INSERT INTO login_info(fname, lname) VALUES ("'.$_POST['firstname'].'","'.$_POST['lasttname'].'")';
 if(!mysql_query($sql, $con)){
  die('error:'.mysql_error());
 }
lhrec_106
  • 630
  • 5
  • 18