Naomba msaada nakosea wapi kwenye kuconnect hii form na database

leoleo-tu

JF-Expert Member
Dec 18, 2018
1,792
5,086
Wakuu, naendelea kujifunza vitu. Sasa sasa hivi najifunza ku interact na database.
Nimeweza kuunda fomu hii kwa msaada wa HTML and CSS
1697219003793.png

Na huu ndiyo code yangu ya HTML
Code:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="styles.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Sign Up</title>
</head>
<body>
    <div class="sign-box">
        <h1>Signup</h1>
        <form action="sign-in.php" method="post">
            <input type="text" class="input-box" placeholder="First name" name="first_name" required>
            <input type="text" class="input-box" placeholder="Second name" name="last_name" required>
            <input type="email" class="input-box" placeholder="Email" name="email" required>
            <input type="password" class="input-box" placeholder="Password" name="password" required>
            <p><span><input type="checkbox" name="agree" value="yes" required>I agree to the terms of the services.</span></p>
            <button type="submit" class="sign-btn">Sign up</button>
            <hr>
            <p class="or">OR</p>
            <button type="button" class="sign-btn">Login with Facebook</button>
            <p>Do you have an account? <a href="#">Login</a></p>
        </form>
    </div>
    
</body>
</html>
Na hii ni php code
Code:
<?php
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$password = $_POST['password'];
$agree = $_POST['agree'];
$conn = new mysqli('localhost','root','','user_signup');
if($conn->connection_error){
    die('Connection Failed : ' .$conn->connection_error);
    }else{
        $stmt = $conn->prepare("INSERT INTO user_credentials(first_name, last_name, email, password, agree) values(?, ?, ?, ?, ?)");
        $stmt->bind_param("sssss", $first_name, $last_name, $email, $password, $agree);
        $stmt->execute();
        echo "Registration succesiful...";
        $stmt->close();
        $stmt->close();
    }
?>
Lakini imekaa kufanya kazi, server ina run na nimeunda data base inaitwa user_signup na table inaitwa user_credentials na nimeset kila kitu kuanzia first_name, last_name, email, password, na agree, nikaweza na value pia.
Ila nikitest php file kwenye browser kwa kuandika directory napata error hii
1697219287234.png


Na nikiweka details nikasubmit ni kama vile hazitumwi kwenye php file maana napata hiki tu:
1697219339546.png

Nimejaribu ku troubleshoot kwa kuiuliza Bardi na Chatgpt na kuipa code zote, na zote zinasema code inaonekana iko sawa.
hapa ninakosea wapi dronedrake
 
Mkuu kule kwenye wifite umetukimbia na text umegoma kujibu.
Mkuu mimi sijakimbia mtu halafu mimi napenda tumia browser kwenye jf so kuna muda sms kuzisoma inakuwa ngumu haifunguki... Mkuu mimi si hacker ile ni tool tu una scan inakupa pssword mkuu ila ni ya linux
 
Mkuu mimi sijakimbia mtu halafu mimi napenda tumia browser kwenye jf so kuna muda sms kuzisoma inakuwa ngumu haifunguki... Mkuu mimi si hacker ile ni tool tu una scan inakupa pssword mkuu ila ni ya linux
Nilikuuliza vipi,
1-ulitumia wifi adapter au ulitumia tu built in ya kwenye PC,
2-Na vipi ulitumia wordlist au hukutumia kama ulitumia (kwa ajili ya dictionary), ulitumia ipi..!?,
3-wifite inadai kuweka Pyrit (Hapo ulichomokaje).
Hayo tu mkuu.
 
Nilikuuliza vipi,
1-ulitumia wifi adapter au ulitumia tu built in ya kwenye PC,
2-Na vipi ulitumia wordlist au hukutumia kama ulitumia (kwa ajili ya dictionary), ulitumia ipi..!?,
3-wifite inadai kuweka Pyrit (Hapo ulichomokaje).
Hayo tu mkuu.
Hakuna cha wordlist, ingia kama super user type wifite enter bas mengine fuata inachokwambia, itakuletea wifi zilizopoa unaweza chagua za kutafta password au ukaamua zote
 
badala ya
Code:
$first_name = $_POST['first_name'];

tumia
Code:
$first_name = isset($_POST['first_name'] ) ? $_POST['first_name']: ' ';
Hii imesolve tatizo langu, sasa iko poa. Nimebaki na tatizo nikisubmit page inanletea code ya php nliyoandika kwenye black window yan haipost details kwenye table
 
$conn = new mysqli('localhost','root','','user_signup');
if($conn->connection_error){
die('Connection Failed : ' .$conn->connection_error); umesokea hapa
 
Mkuu hapo umekosea sehemu nyingi sana hapo hutoweza ku insert data kwenye database
code mpya ni hii mkuu yah kulikuwa na typos, nimezitoa na nikiirun inaletes kuwa iko sucessiful: Ila nikisubmit form inanileta code ya php kwenye black window:

code ni hii
Code:
<?php
$first_name = isset($_POST['first_name'] ) ? $_POST['first_name']: ' ';
$last_name = isset($_POST['last_name'] ) ? $_POST['last_name']: ' ';
$email = isset($_POST['email'] ) ? $_POST['email']: ' ';
$password = isset($_POST['password'] ) ? $_POST['password']: ' ';
$agree = isset($_POST['agree'] ) ? $_POST['agree']: ' ';
$conn = new mysqli('localhost','root','','user_signup');
if($conn->connect_error){
    die('Connection Failed : ' .$conn->connection_error);
    }else{
        $stmt = $conn->prepare("INSERT INTO user_credentials(first_name, last_name, email, password, agree) values(?, ?, ?, ?, ?)");
        $stmt->bind_param("sssss", $first_name, $last_name, $email, $password, $agree);
        $stmt->execute();
        echo "Registration succesiful...";
        $stmt->close();
        $conn->close();
    }
?>
nikiiruni napata
1697224525180.png

nikisubmit fomu napata
1697224585815.png
 
$conn = new mysqli('localhost','root','','user_signup');
if($conn->connection_error){
die('Connection Failed : ' .$conn->connection_error); umesokea hapa
Hapa nshaparekebisha mkuu nilikosea kweli, ila bado sijaweza kusubmit details nimekuwa screenshots pia
 
Tumia if isset(POST

$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$password = $_POST['password'];
$agree = $_POST['agree'];
 
code mpya ni hii mkuu yah kulikuwa na typos, nimezitoa na nikiirun inaletes kuwa iko sucessiful: Ila nikisubmit form inanileta code ya php kwenye black window:

code ni hii
Code:
$first_name = isset($_POST['first_name'] ) ? $_POST['first_name']: ' ';
$last_name = isset($_POST['last_name'] ) ? $_POST['last_name']: ' ';
$email = isset($_POST['email'] ) ? $_POST['email']: ' ';
$password = isset($_POST['password'] ) ? $_POST['password']: ' ';
$agree = isset($_POST['agree'] ) ? $_POST['agree']: ' ';
$conn = new mysqli('localhost','root','','user_signup');
if($conn->connect_error){
die('Connection Failed : ' .$conn->connection_error);
}else{
$stmt = $conn->prepare("INSERT INTO user_credentials(first_name, last_name, email, password, agree) values(?, ?, ?, ?, ?)");
$stmt->bind_param("sssss", $first_name, $last_name, $email, $password, $agree);
$stmt->execute();
echo "Registration succesiful...";
$stmt->close();
$conn->close();
}
?>
nikiiruni napata
View attachment 2781247
nikisubmit fomu napata
View attachment 2781252
Hapo tayari data zimeshaingi cheki database yako
 
Back
Top Bottom