Registration form hait insert data katika table za database

Deejay nasmile

JF-Expert Member
Nov 8, 2011
5,773
5,322
Wakuu habari,nimejaribu kutengeneza php reg form, pia niwetengeneza database yenye table na field zote kama
nilizo create ktk forms. sasa nashindwa kutengeneza connection ili mtu akishajaza ile form,data ziende ktk db nilizocreate.afu pia ziweze kuonekana ktk page ya user panel. Natumia xamp server
 
Weka code zako hapa tukuchapie
 
Database connection:
<?php $connect = new Mysqli($hostname,$username,$password,$dbname);

//test connection if
if($connect->error){
print "Database connection failed";
}
else{
print "Database connection is made!!!!";
}
 
Database connection:
<?php $connect = new Mysqli($hostname,$username,$password,$dbname);

//test connection if
if($connect->error){
print "Database connection failed";
}
else{
print "Database connection is made!!!!";
}
Mkuu hiyo ni file linalojitegemea au naunganisha ndani ya file la register.php???? Sehemu gani
 
Mkuu hiyo ni file linalojitegemea au naunganisha ndani ya file la register.php???? Sehemu gani
Linajitegemea then unaweza kuritumia sehemu yoyote unapotaka kutumia database. Unaweza kutumia ata kwenye file lako la register kwa kutumia require_once("dbconnection.php") juu ya file lako ya register.php
 
Linajitegemea then unaweza kuritumia sehemu yoyote unapotaka kutumia database. Unaweza kutumia ata kwenye file lako la register kwa kutumia require_once("dbconnection.php") juu ya file lako ya register.php
Kwa mfano kwenye file lako la register

<?php

require_once("dbconnection.php");
//dbconnection save as separate file

$username = $connect->real_string_escape($_POST["username"]);
$password = $connect->real_string_escape($_POST["password"]);

$query = $connect->query("INSERT INTO members VALUES(username = '$username', password = '$password'");

if($query){

print "Successfully";
}

else{
print "Failed to insert member";

}


?>
 
Bado ni mziki mnene!!! Kila nikisubmit inakuja blank page au nikienda kwenye db hamna new record yoyote
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…