Jump to content

sigridish

New Members
  • Posts

    2
  • Joined

  • Last visited

sigridish's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hi all! im kind of not use to using php. i wanted to have a table where it will display names of the employee and then add some radio buttons and a clock maybe? to cut it short, here is a picture and a bit of info
  2. Hi all! I would like to ask for help. i have a code that i got from youtube. my problem is i cant connect to my database and i dont know why. i dont think that i have a problem in my code. i have 2 php file. reg.php for the connection and demo-form.php for adding the record. demo-form.php <form action="reg.php" method="post" /> <p>First Name: <input type="text" name="fname" /> </p> <p>Middle Name: <input type="text" name="mname" /> </p> <p>Last Name: <input type="text" name="lname" /> </p> <p>Home address: <input type="text" name="homeadd" /> </p> <p>Email address: <input type="text" name="emailadd" /> </p> <p>Office/project number: <input type="text" name="ofcnum" /> </p> <p>Mobile number: <input type="text" name="mobilenum" /> </p> <p>Home number: <input type="text" name="homenum" /> </p> <p>Position: <select name="position"> <option value ="">Select</option> <option value ="Project Manager">Project Manager</option> <option value ="Practice Lead">Project Manager</option> <option value ="Team Leader">Team Leader</option> <option value ="Team Member">Team Member</option> </select> <p>Practice: <select name="position"> <option value ="">Select</option> <option value ="Solutions">Solutions</option> <option value ="Outsourcing">Outsourcing</option> </select> <p>Project Name: <input type="text" name="projname" /> </p> <p>Project Manager: <input type="text" name="projmgr" /> </p> <p>Team Leader: <input type="text" name="teamlead" /> </p> <input type="submit" value="Submit" /> <body bgcolor="cccccc"> </form> reg.php <?php[/b] [b]define ('DB_NAME', 'emp'); define ('DB_USER', 'root'); define ('DB_PASSWORD', ''); define ('DB_HOST', 'localhost');[/b] [b]$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);[/b] [b]if (!$link) { die('Could not connect: ' . mysql_error()); }[/b] [b]$db_selected = mysql_select_db(DB_NAME, $link);[/b] [b]if (!$db_selected) { die('Can\'t use ' . DB_NAME . ': ' . mysql_error()); }[/b] [b]$value1 = $_POST["fname"]; $value2 = $_POST["mname"]; $value3 = $_POST["lname"]; $value4 = $_POST["homeadd"]; $value5 = $_POST["emailadd"]; $value6 = $_POST["ofcnum"]; $value7 = $_POST["mobilenum"]; $value8 = $_POST["homenum"]; $value9 = $_POST["position"]; $value10 = $_POST["practice"]; $value11 = $_POST["projname"]; $value12 = $_POST["projmgr"]; $value13 = $_POST["teamlead"];[/b] [b]$sql = "INSERT INTO employee (fname, mname, lname, homeadd, emailadd, ofcnum, mobilenum, homenum, position, projname, projmgr, teamlead) VALUES ('$value1', '$value2', '$value3', '$value4', '$value5', '$value6', '$value7', '$value8', '$value9', '$value10', '$value11', '$value12')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); }[/b] [b]mysql_close();[/b] [b]?>
×
×
  • 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.