从端口8080访问mysql

时间:2014-03-14 16:22:54

标签: php mysql database phpmyadmin cherrypy

我无法从localhost访问phpmyadmin:8080我在哪里托管我的网络应用程序(使用cherrypy)。我有另一个应用程序在端口80(使用Apache2)运行,所以我不能在那里运行我的樱桃应用程序。

我可以在localhost / phpmyadmin访问phpmyadmin,并创建了一个名为cherry的用户,数据库hospital,其中包含表patient

如何将这些数据插入数据库?

我在dbmgmt.php的HTML:

        <form method="post" action="addEntry.php">
        <fieldset data-role="collapsible">
            <legend>New Entry</legend>
            <label for="patientID">Patient ID:</label>
            <input name="patientID" id="patientID" placeholder="2 characters follow by 3 digits" value="" type="text" required>
            <label for="firstname">Patient Name:</label>
            <input name="firstname" id="firstname" placeholder="First Name" value="" type="text" required>
            <input name="lastname" id="lastname" placeholder="Last Name" value="" type="text">
            <label for="patientIC">Patient IC:</label>
            <input name="patientIC" id="patientIC" placeholder="Patient IC" value="" type="text" required>
            <label for="address">Address:</label>
            <input name="address" id="address" placeholder="Address" value="" type="text">
            <label for="phone">Phone Number:</label>
            <input name="phone" id="phone" placeholder="Phone Number" value="" type="text">

            <input value="Submit" type="submit">
        </fieldset>
    </form>

addEntry.php:

<?php

$patientID = $_POST['patientID'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$patientIC = $_POST['patientIC'];
$address = $_POST['address'];
$phone = $_POST['phone'];
@ $db = new mysqli('localhost', 'cherry', 'lalalulu', 'hospital');
if (mysqli_connect_errno()) {
     echo 'Error: Could not connect to database.  Please try again later.';
     exit;
}
mysqli_query($db,"INSERT INTO patient (patient_ID, first_name, last_name, patient_IC, address, phone)
VALUES ('$patientID', '$firstname', '$lastname', '$patientIC', '$address', '$phone')");

header ('Location: dbmgmt.php');
?>

0 个答案:

没有答案