Answered step by step
Verified Expert Solution
Question
1 Approved Answer
$conn = mysqli _ connect ( $servername, $username, $password, $dbname ) ; / / if ( ! $conn ) { die ( Connection failed:
$conn mysqliconnect$servername, $username, $password, $dbname; if $conn dieConnection failed: mysqliconnecterror; if $SERVERREQUESTMETHOD" "POST" if empty$POSTname && empty$POSTdateofbirth" && empty$POSTphone && empty$POSTcentername" && empty$POSTreservationdate" $name $POSTname; $dateofbirth $POSTdateofbirth"; $phone $POSTphone; $centername $POSTcentername"; $reservationdate $POSTreservationdate"; ID $centerid null; $stmt $connprepareSELECT centerid FROM PBloodCenter WHERE centername ; if $stmt diePrepare failed: $connerror; $stmtbindparams $centername; $stmtexecute; $stmtbindresult$centerid; $stmtfetch; $stmtclose; if $centerid null dieCenter ID not found"; ID $donorid getDonorid$conn, $phone; ID if $donorid ID insertPDonation$conn, $donorid $centerid $reservationdate; else ID $donorid insertPDonor$conn, $name, $dateofbirth, $phone; if $donorid insertPDonation$conn, $donorid $centerid $reservationdate; else echo "alertError adding new donor';; else echo "alertAll fields must be filled out';; $stmtclose; function insertPDonation$conn, $donorid $centerid $reservationdate $stmt $connprepareINSERT INTO PDonation centerid reservationdate, donorid VALUES ; if $stmt diePrepare failed: $connerror; $stmtbindparamiss $centerid $reservationdate, $donorid; if $stmtexecute echo "alertData Inserted Successfully';; else echo "alertError Inserting Data: $stmterror ;; $stmtclose; function insertPDonor$conn, $name, $dateofbirth, $phone $stmt $connprepareINSERT INTO PDonor name dateofbirth, phone VALUES ; if $stmt diePrepare failed: $connerror; $stmtbindparamsss $name, $dateofbirth, $phone; if $stmtexecute return $stmtinsertid; else echo "alertError Inserting Donor: $stmterror ;; return null; $stmtclose; function getDonorid$conn, $phone $stmt $connprepareSELECT donorid FROM PDonor WHERE phone ; if $stmt diePrepare failed: $connerror; $stmtbindparams $phone; $stmtexecute; $stmtbindresult$donorid; $stmtfetch; $stmtclose; return $donorid; I omitted some codes including connection info. connection doesn't have any problems I tried to insert data in DB when form in this html file registered. But nothing happens including error text. What's the matter?
$conn mysqliconnect$servername, $username, $password, $dbname;
if $conn
dieConnection failed: mysqliconnecterror;
if $SERVERREQUESTMETHOD" "POST"
if empty$POSTname && empty$POSTdateofbirth" && empty$POSTphone && empty$POSTcentername" && empty$POSTreservationdate"
$name $POSTname;
$dateofbirth $POSTdateofbirth";
$phone $POSTphone;
$centername $POSTcentername";
$reservationdate $POSTreservationdate";
ID
$centerid null;
$stmt $connprepareSELECT centerid FROM PBloodCenter WHERE centername ;
if $stmt
diePrepare failed: $connerror;
$stmtbindparams $centername;
$stmtexecute;
$stmtbindresult$centerid;
$stmtfetch;
$stmtclose;
if $centerid null
dieCenter ID not found";
ID
$donorid getDonorid$conn, $phone;
ID
if $donorid
ID
insertPDonation$conn, $donorid $centerid $reservationdate;
else
ID
$donorid insertPDonor$conn, $name, $dateofbirth, $phone;
if $donorid
insertPDonation$conn, $donorid $centerid $reservationdate;
else
echo "alertError adding new donor';;
else
echo "alertAll fields must be filled out';;
$stmtclose;
function insertPDonation$conn, $donorid $centerid $reservationdate
$stmt $connprepareINSERT INTO PDonation centerid reservationdate, donorid VALUES ;
if $stmt
diePrepare failed: $connerror;
$stmtbindparamiss $centerid $reservationdate, $donorid;
if $stmtexecute
echo "alertData Inserted Successfully';;
else
echo "alertError Inserting Data: $stmterror ;;
$stmtclose;
function insertPDonor$conn, $name, $dateofbirth, $phone
$stmt $connprepareINSERT INTO PDonor name dateofbirth, phone VALUES ;
if $stmt
diePrepare failed: $connerror;
$stmtbindparamsss $name, $dateofbirth, $phone;
if $stmtexecute
return $stmtinsertid;
else
echo "alertError Inserting Donor: $stmterror ;;
return null;
$stmtclose;
function getDonorid$conn, $phone
$stmt $connprepareSELECT donorid FROM PDonor WHERE phone ;
if $stmt
diePrepare failed: $connerror;
$stmtbindparams $phone;
$stmtexecute;
$stmtbindresult$donorid;
$stmtfetch;
$stmtclose;
return $donorid;
I omitted some codes including connection info. connection doesn't have any problems I tried to insert data in DB when form in this html file registered. But nothing happens including error text. What's the matter?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started