The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

2 Pages V < 1 2  
Reply to this topicStart new topic
> problem inserting data to PHP Database using mysqli
dariusd7
post Sep 13 2014, 08:30 PM
Post #21


Newbie
*

Group: Members
Posts: 16
Joined: 9-September 14
Member No.: 21,528



Don't laugh but I figured out what the problem is. First I want to think you for all your suggestions..As it did help me find other errors and make some correction to my code. But what the problem was.. I needed to actually type the URL in for the HTML page.. when I did that and entered the data, click submit..the data got inserted into the database and the PHP code did not show up in the browser window.. What I was doing was while I was in Notepad++ i would go to run and click on chrome.. or I would go into the Htdoc file and click on the html page there.. neither of those ways worked..but when I typed in the url..it worked..
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Sep 15 2014, 02:18 AM
Post #22


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



Your description is not 100% clear, but it sound like exactly what you would expect. If you just load a php file into your *browser*, obviously you will see the php file, which is a program. If you want to *run* the php program, normally you use a web *server* (either remote, or on your own machine) to run the php program, and send the output to a browser.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Sep 15 2014, 03:24 AM
Post #23


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



You should also consider some validation messages to the user. This test (mis-spellings need correction):
CODE
  if(isset($_POST['first_name'], $_POST['lats_name'],$_POST['student_id'],$_POST['email'],
            $_POST['major'],$_POST['examName'],$_POST['taken_class'],$_POST['className'],
            $_POST['prepare'],$_POST['measureUpKey'],$_POST['examDate']))
will prevent a submit if any required field is blank but it doesn't tell the user anything. The user will just click submit and nothing will happen and they won't know why. You should not depend on javascript validation because users can turn it off. You should also sanitize the user input and escape it using mysqli_real_escape_string before posting it into the database (to help guard against SQL injection attacks).
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

2 Pages V < 1 2
Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 08:32 PM