SOME DATA IS NOT BEING INSERTED TO MYSQL DATABASE WITH PHP
2016-10-03, 07:30 PM, (This post was last modified: 2016-10-03, 07:41 PM by QwertySon.)
#1
PHP Code:
<?php
$host 
'localhost';
$username 'root';
$password '';
$datadase 'registerfinal';
$connect mysqli_connect($host$username$password) or die ('error to connect to datadase'.mysqli_error());
if (
$connect) {
    echo 
'mysqli connect succsessfull';
}
echo 
'<br /><br />';
$selectdb mysqli_select_db($connect$datadase) or die ('unable to select datadase'.mysqli_error());
if(
$selectdb) {
    echo 
'database selected succsessfully';
}

if(isset(
$_POST['savedetails'])) {
        
    
$firstname $_POST['firstname'];
    
$lastname $_POST['lastname'];
    
$username $_POST['username'];
    
$password $_POST['password'];
    
$repeat_password $_POST['repeat_password'];
    
$gender $_POST['gender'];
    
$country $_POST['country'];
    
    
    if(isset(
$_POST['food'])) {
    
$food $_POST['food'];
    
$favfood "";
    foreach(
$food as $meal ) {
    
$favfood $meal.",";    
    
print_r($favfood);
    }
}
    
    if(isset(
$_POST['imageUpload'])) {
    
$imageUploadname $_FILES['imageUpload']['name'];
    
$imageUploadsize $_FILES['imageUpload']['size'];
    
$imageUploadtmp_name $_FILES['imageUpload']['tmp_name'];
    
$imageUploadtype $_FILES['imageUpload']['type'];
    
$uploadFolder "uploadFolder/";
    
$destinationName rand(100010000).$imageUploadname;    
    
    
move_uploaded_file($imageUploadtmp_name$uploadFolder.$destinationName);
    echo 
"$imageUploadname";
    echo 
"$imageUploadsize";
    echo 
"$imageUploadtmp_name";
    echo 
"$imageUploadtype";
    echo 
"$destinationName";
    
    }
    
$sqltwo "INSERT INTO `registerfinaltable` (`id`, `firstname`, `lastname`, `username`, `password`, `repeat_password`, 
    `gender`, `food`, `country`, `imageUploadname`, `imageUploadsize`, `imageUploadtype`)
    VALUES (NULL, '
$firstname', '$lastname', '$username', '$password', '$repeat_password', '$gender', '$favfood', '$country',
    '
$destinationName', '$imageUploadsize', '$imageUploadtype')";
    
    
$results mysqli_query($connect$sqltwo) ;
    if(
$results){
        
    echo 
"inserted successfully";
    }
}

?>


<html>
<head>
<title>register</title>

</head>

<body>
<form action = "" method = "post"  enctype = "multipart/form-data"  >
<label>first name : <input type = "text" name = "firstname" /> </label> <br /><br />
<label>last name : <input type = "text" name = "lastname" /> </label><br /><br />
<label>username : <input type = "text" name = "username" /> </label><br /><br />
<label>password : <input type = "password" name = "password" /> </label><br /><br />
<label>repeat password : <input type = "password" name = "repeat_password" /> </label><br /><br />
<label>Male :   <input type = "radio" name = "gender" value = "Male" /> </label><br /><br />
<label>Female : <input type = "radio" name = "gender"  value = "Female" /> </label><br /><br />
<label>pizza : <input type = "checkbox" name = "food[]" value = "pizza"/> </label><br /><br />
<label>burger : <input type = "checkbox" name = "food[]" value = "burger"/> </label><br /><br />
<label>chips : <input type = "checkbox" name = "food[]" value = "chips"/> </label><br /><br />
<label>sausage : <input type = "checkbox" name = "food[]" value = "sausage"/> </label><br /><br />
<label>sandwich : <input type = "checkbox" name = "food[]" value = "sandwich"/> </label><br /><br />
<label>Image : <input type = "file" name = "imageUpload" /> </label><br /><br />
<select name = "country">
<?php
$sql 
'SELECT * FROM `countrie` ';
$querry mysqli_query($connect$sql);
while(
$country mysqli_fetch_array($querry)):;

?>

<option value = "<?php echo $country['country']; ?>"><?php echo $country['country']; ?></option>
<?php endwhile;?>


</select> <br />


<input type = "submit" name = "savedetails" />



</form>
<table border = "1" bgcolor = "" width = "100%">
<tr><th>id</th><th>Firstname</th><th>Lastname</th><th>Username</th><th>Password</th><th>Password 2</th><th>Gender</th><th>Fav. Food</th> <th>Image</th> <th>Country</th><th>imageUploadname</th><th>imageUploadsize</th><th>imageUploadtype</th></tr>
<?php 
$sqldata 
"SELECT * FROM registerfinaltable";
$querysqldata mysqli_query($connect$sqldata);
while(
$rows mysqli_fetch_array($querysqldata) ):;
?>
<tr>
<td><?php echo $rows['id'];?></td>
<td><?php echo $rows['firstname'];?></td>
<td><?php echo $rows['lastname'];?></td>
<td><?php echo $rows['username'];?></td>
<td><?php echo $rows['password'];?></td>
<td><?php echo $rows['repeat_password'];?></td>
<td><?php echo $rows['lastname'];?></td>
<td><?php echo $rows['gender'];?></td>
<td><?php echo $rows['food'];?></td>
<td><?php echo $rows['country'];?></td>
<td><?php echo $rows['imageUploadname'];?></td>
<td><?php echo $rows['imageUploadsize'];?></td>
<td><?php echo $rows['imageUploadtype'];?></td>
<?php endwhile;?>
</tr>
</table>
</body>
</html> 

[Image: a17baebbce8a2df4f1f1efb269e8f5e1.png]
Reply
2016-10-07, 01:08 AM,
#2
Hi,let's chat on skype,i will help you ;)
Reply
2016-11-21, 02:52 PM,
#3
(2016-10-07, 01:08 AM)MIG92 Wrote: Hi,let's chat on skype,i will help you ;)

thanks though i got the solution
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Help Needed CPAgrip php script takumi 4 843 2017-01-24, 04:47 AM
Last Post: takumi
  php + mysql , I need help t0ks1ck 4 1,060 2016-09-19, 01:55 AM
Last Post: styx
  need a php line help t0ks1ck 8 1,058 2016-09-08, 09:01 PM
Last Post: styx
  Data Publisher - #1 Publisher Registration Tool datagroove 0 679 2016-04-30, 04:33 PM
Last Post: datagroove
  Looking for php - Coder tbonemaker 0 621 2016-02-29, 10:20 PM
Last Post: tbonemaker





About Us | Contact Us | CPA Elites | Advertise | Stats | Staff Team

© 2013-2017 CPA Elites Ltd
Enhanced by MyBB and WallBB
Return to top