Jump to content

Unable to save submitted data in a MySQL database using PHP


Johngm

Recommended Posts

<?php $GLOBALS['title']="Admission-HMS"; $base_url="http://localhost/hms/"; require('./../../inc/sessionManager.php'); require('./../../inc/dbPlayer.php'); require('./../../inc/fileUploader.php'); require('./../../inc/handyCam.php'); $ses = new \sessionManager\sessionManager(); $ses->start(); if($ses->isExpired()) { header( 'Location:'.$base_url.'login.php'); } else { $name=$ses->Get("loginId"); } $msg=""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (isset($_POST["btnSave"])) { $db = new \dbPlayer\dbPlayer(); $msg = $db->open(); echo '<script type="text/javascript"> alert("'.$msg.'");</script>'; if ($msg = "true") { $userIds = $db->getAutoId("U"); $flup = new fileUploader\fileUploader(); $perPhoto = $flup->upload("/hms/files/photos/",$_FILES['perPhoto'], $userIds[1]); // var_dump($perPhoto); $handyCam=new \handyCam\handyCam(); if (strpos($perPhoto, 'Error:') === false) { $dateNow=date("Y-m-d"); $data = array( 'userId' => $userIds[1], 'userGroupId' => "UG004", 'name' => $_POST['name'], 'studentId' => $_POST['stdId'], 'cellNo' => $_POST['cellNo'], 'gender' => $_POST['gender'], 'dob' => $handyCam->parseAppDate($_POST['dob']), 'passportNo' => $_POST['passportNo'], 'fatherName' => $_POST['fatherName'], 'fatherCellNo' => $_POST['fatherCellNo'], 'perPhoto' => $perPhoto, 'admitDate' => $dateNow, 'isActive' => 'Y' ); $result = $db->insertData("studentinfo",$data); if($result>=0) { $data = array( 'userId' => $userIds[1], 'userGroupId' => "UG004", 'name' => $_POST['name'], 'loginId' => $_POST['stdId'], 'verifyCode' => "vhms2115", 'expireDate' => "2115-01-4", 'isVerifed' => 'Y' ); $result=$db->insertData("users",$data); if($result>0) { $id =intval($userIds[0])+1; $query="UPDATE auto_id set number=".$id." where prefix='U';"; $result=$db->update($query); // $db->close(); echo '<script type="text/javascript"> alert("Admitted Successfully.");</script>'; } else { echo '<script type="text/javascript"> alert("' . $result . '");</script>'; } } elseif(strpos($result,'Duplicate') !== false) { echo '<script type="text/javascript"> alert("Student Already Exits!");</script>'; } else { echo '<script type="text/javascript"> alert("' . $result . '");</script>'; } } else { echo '<script type="text/javascript"> alert("' . $perPhoto . '");</script>'; } } else { echo '<script type="text/javascript"> alert("' . $msg . '");</script>'; } }

Link to comment
Share on other sites

What is this?  A picture?  Can you not choose the area where you think the problem is and help us focus in on actual code that needs looking at - not peering at with a magnifier?  Have you not posted on any forum before?  Show Us The Code please.  And not all of it!

BTW - what debugging have you done?  Any echos to show the query that you have built to do this?  Echos to show where your logic is taking you?  An echo to show the success or failure of the query? Anything?

Edited by ginerjm
Link to comment
Share on other sites

MInd my wording?  I am just frustrated at the lack of responsiveness from you.  It has been pointed out twice to post your code (the part that matters if you have found it) yet you still haven't.   How can it be made more clear?

Please  - try again.  Please.

Link to comment
Share on other sites

Yes i mean your language, You have a big problem with common decency. There is no just  reason as to why you should be frustrated not even if i don't respond or its pointed a million times. 

Its simple, if you are enable or am too much as per your own standards, kindly  ignore the question!!

Link to comment
Share on other sites

Normally, when someone posts a large amount of code, I'll copy and paste it into my code editor and check for errors and, in this case, search for the SQL bits.

Tell me how to do that with a picture of the code. It's further obfuscated as all the database activity seems to happen inside the $db object EG

image.png.a290ff153c6c4699e789504430bcae6d.png

so there is no way we can even see the query that is being executed or what may be happening.

Are there any error messages? Are you even checking for errors? Have you checked the error log?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.