Jump to content

jiameow

Members
  • Posts

    19
  • Joined

  • Last visited

Posts posted by jiameow

  1.  

    Ok , and now:

     

     

    echo "<input type=\"submit\" name=\"submit\" value=\"Finish Registration!\" />";
    
    echo "</form>";
    
    
    
    }else {
     
    // here
    
     
    
    echo '<pre>'.print_r($_POST['services'], true).'</pre>'; exit;
    
    
    $service = protect($_POST['services']);
    
     
    

    still the same :/

  2.  

    Ok, then!

     

    Put the error_reporting(-1) to the top of the file and tell us what error(s) do you get?

     

    Copy/Paste my script!

     

    <?php
    error_reporting(-1);
    include_once "add2.php";
    connect();
    
    if (!isset($_POST['submit'])){
    echo "<form method=\"post\" action=\"admin-addservice.php\" name=\"Registration Form\">";
    echo "<br/>";
    echo 'Name of Service: ' . '<br/>' . '<input type=\"text\" name=\"services\" style="width:400px;"/>' . '<br/>' . '<br/>';
    echo "Description: " . "<br/>";
    //echo '<textarea cols="80" rows="10" name=\"description\" maxlength=\"1000\" style=\"overflow: hidden;\">';
    //echo '</textarea>' . '<br/>' . '<br/>';
    echo "<input type=\"text\" name=\"\">";
    echo "Price: " . '<br/>';
    echo "<input type=\"text\" name=\"price\" style='width:200px;'/>" . '<br/>';
    echo "<input type=\"submit\" name=\"submit\" value=\"Finish Registration!\" />";
    echo "</form>";
    
    }else {
    
    $service = protect($_POST['services']);
    $description = protect($_POST['description']);
    $price = protect($_POST['price']);
    
    $errors = array();
    if(!$service) {
    $errors[] = "Invalid Name of Service!";
    }
    if(!$description) {
    $errors[] = "Invalid Description!";
    }
    if(!$price) {
    $errors[] = "Invalid Price!";
    }
    if (count($errors) > 0) {
    foreach($errors AS $error) {
    echo ("<SCRIPT LANGUAGE='JavaScript'>
    window.alert('$error')
    window.location.href='admin-addservice.php'
    </SCRIPT>");
    }
    }
    else {
    $sql = "INSERT INTO services(services , description , price) VALUES('$_POST[services]' , '$_POST[description]' , '$_POST[price]')";
    $res = mysql_query($sql) or die (mysql_error());
    ?>
    <script type="text/javascript">
    function show_alert() {
    var msg = "Successfully Saved!";
    alert(msg);
    }
    </script>
    <?php
    
    echo "<br/>";
    echo '<script type="text/javascript"> show_alert(); </script>';
    echo "<br/>";
    echo "<br/>";
    echo "<br/>";
    
    }
    }
    

    invalid name of service!

     

    "Undefined index: service D:\xampp\htdocs\def\admin-addservice.php on line 93

  3. Me too.

     

    What do you have in the add2.php file?

    <?php

     

    function protect($string)

    {

    $string = mysql_real_escape_string($string);

    $string = strip_tags($string);

    $string = addslashes($string);

     

    return $string;

     

    }

    function connect () {

    $con = mysql_connect("localhost", "root",'') or die(mysql_error());

    $db = mysql_select_db("patient", $con);

     

    }

     

    ?>

  4. here is our full code

     

     


    <?php
    include_once "add2.php";
    connect();

    mysql_connect("localhost","root","");
    mysql_select_db("patient");

    if (!isset($_POST['submit'])){
    echo "<form method=\"post\" action=\"admin-addservice.php\" name=\"Registration Form\">";
    echo "<br/>";
    echo 'Name of Service: ' . '<br/>' . '<input type=\"text\" name=\"services\" style="width:400px;"/>' . '<br/>' . '<br/>';
    echo "Description: " . "<br/>";
    //echo '<textarea cols="80" rows="10" name=\"description\" maxlength=\"1000\" style=\"overflow: hidden;\">';
    //echo '</textarea>' . '<br/>' . '<br/>';
    echo "<input type=\"text\" name=\"\">";
    echo "Price: " . '<br/>';
    echo "<input type=\"text\" name=\"price\" style='width:200px;'/>" . '<br/>';
    echo "<input type=\"submit\" name=\"submit\" value=\"Finish Registration!\" />";
    echo "</form>";

    }else {

    $service = protect($_POST['services']);
    $description = protect($_POST['description']);
    $price = protect($_POST['price']);

    $errors = array();
    if(!$service) {
    $errors[] = "Invalid Name of Service!";
    }
    if(!$description) {
    $errors[] = "Invalid Description!";
    }
    if(!$price) {
    $errors[] = "Invalid Price!";
    }
    if (count($errors) > 0) {
    foreach($errors AS $error) {
    echo ("<SCRIPT LANGUAGE='JavaScript'>
    window.alert('$error')
    window.location.href='admin-addservice.php'
    </SCRIPT>");
    }
    }
    else {
    $sql = "INSERT INTO services(services , description , price) VALUES('$_POST[services]' , '$_POST[description]' , '$_POST[price]')";
    $res = mysql_query($sql) or die (mysql_error());
    ?>
    <script type=text/javascript>
    function show_alert() {
    var msg = "Successfully Saved!";
    alert(msg);
    }
    </script>
    <?php

    echo "<br/>";
    echo '<script type="text/javascript"> show_alert(); </script>';
    echo "<br/>";
    echo "<br/>";
    echo "<br/>";

    }
    }

    ?>
  5. <?php
    include_once "add2.php";
    connect();
    ?>

    <?php
    if (!isset($_POST['submit'])){

    echo "<form method=\"post\" action=\"admin-addservice.php\" name=\"Registration Form\">";
    echo "<br/>";
    echo 'Name of Service: ' . '<br/>' . '<input type=\"text\" name=\"service\" style="width:400px;"/>' . '<br/>' . '<br/>';
    echo "Description: " . "<br/>";
    echo '<textarea cols="80" rows="10" name=\"description\" maxlength=\"1000\" style=\"overflow: hidden;\">';
    echo '</textarea>' . '<br/>' . '<br/>';
    echo "Price: " . '<br/>';
    echo "<input type=\"text\" name=\"price\" style='width:200px;'/>" . '<br/>';
    echo "<input type=\"submit\" name=\"submit\" value=\"Finish Registration!\" />";
    echo "</form>";

    ?>
    <?php

    }else {

    $service = protect($_POST['service']);
    $description = protect($_POST['description']);
    $price = protect($_POST['price']);

    $errors = array();

×
×
  • 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.