Jump to content

biggieuk

Members
  • Posts

    159
  • Joined

  • Last visited

Posts posted by biggieuk

  1. Im looking to explore Ajax within the next few weeks, for this i just need a quick working solution so that i can get it finished.

     

    Currently after pressing submit, a confirmation page is loaded displaying the details from the page before. I would need to have a page in between that could check the session capacity is not full before proceeding, otherwise the page is displayed showing the error and a back button so they can return to the booking form?

  2. Hi all,

     

    Currently my form performs a validation function when the submit button is clicked.

     

                      <input name="Submit" type="submit" id="Submit" value="Submit">
    
    
    <form action="confirmation.php" method="post" enctype="multipart/form-data" name="booking" id="booking" onSubmit="return checkRadios()">
    

     

    How can i also check with my MYSQL database to see if 'capacity' is the same as 'placesbooked' and display an error message to the user saying which sessions are fully booked and return to the form so they can change their selection?

     

    I am trying to do this so that people do not book themselves onto a session that is already filled.

     

    Thanks for help with this,

     

    Dan

  3. Hi all,

    I have an admin page for my booking system with a listbox that is populated by the 'surname' field in the database.

    When a certain surname is selected i would like the details for that surname to populate the other textboxes on the admin page. firstname, address, tel etc..

    This could then be editable and can be resubmitted to the database.

    Im unsure on how to pass the listbox value into a query to receive the data and display it into the other boxes?

    Thanks very much.

    Dan

  4. Hi,

    I added <?php if($placesbooked==$capacity) echo "disabled";?> to the value of each radiobutton.

    This makes each radiobutton disabled and doesnt check that  '$placesbooked==$capacity'.

    Do i need to assign the variables $placesbooked & $capacity to the value in the database for this to work?

    [code]<?php <input name="session1" type="radio" value="T6" <? if($placesbooked==$capacity) echo "disabled";?>> ?>[/code]

    thanks for your help,

    Dan
  5. Hi all,

    Im having trouble with a certain function on my booking form.

    In my database i have a 'session' table which contains  sessionid,capacity,placesbooked

    On the form i have a few textboxes name,email,address etc.. and 45 radio buttons split into 4 groups. Each radio button corresponds to a sessionid.

    I want the booking form to check and see if any values in 'placesbooked' are equal to the capacity and if so disable the radiobutton on the form which corresponds to the sessionid value so that it is unclickable.

    Whats the best approach to this as i am stuck :(

    thanks for your help.
  6. I managed to get this working but still need a little help.

    What is the correct syntax for this:

    [code]
    <?php
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "booking")) {
      $updateSQL = sprintf("UPDATE session SET placesbooked= placesbooked +1 WHERE sessionid=%s,",
                          GetSQLValueString($_POST['hiddenTA'], "text"),
    ?>
    [/code]

    To add 1 to the table where session id = more than 'hiddenTA'?

    I tried:

    [code]
    <?php
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "booking")) {
      $updateSQL = sprintf("UPDATE session SET placesbooked= placesbooked +1 WHERE sessionid=%s,%s,%s,%s",
                          GetSQLValueString($_POST['hiddenTA'], "text"),
          GetSQLValueString($_POST['hiddenTP'], "text"),
          GetSQLValueString($_POST['hiddenFA'], "text"),
          GetSQLValueString($_POST['hiddenFP'], "text"));
    ?>
    [/code]

    But get an error  :(


    Error:  You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'T8'',''T20'',''F7'',''F20''' at line 1
    Thanks.
  7. Hi,

    Im having problems when trying to UPDATE a record in my mysql database.

    The php form sends data to the database ok but i want the update query to add 1 to the 'placesbooked' column where 'sessionid' = the value in 'hiddenTA'.

    I receive the following error:

    Parse error: parse error in /u2/WWW/htdocs/pesdc/confirmation.php on line 59


    Here is my code:

    [code]
    <?php require_once('Connections/PESDC_MYSQL.php'); ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }

    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "booking")) {
      $insertSQL = sprintf("INSERT INTO students (id, TA, TP, FA, FP, forename, surname, email, course, `year`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                          GetSQLValueString($_POST['id'], "int"),
                          GetSQLValueString($_POST['hiddenTA'], "text"),
                          GetSQLValueString($_POST['hiddenTP'], "text"),
                          GetSQLValueString($_POST['hiddenFA'], "text"),
                          GetSQLValueString($_POST['hiddenFP'], "text"),
                          GetSQLValueString($_POST['hiddenforename'], "text"),
                          GetSQLValueString($_POST['hiddensurname'], "text"),
                          GetSQLValueString($_POST['hiddenemail'], "text"),
                          GetSQLValueString($_POST['hiddencourse'], "text"),
                          GetSQLValueString($_POST['hiddenhiddenyear'], "int"));
     

      mysql_select_db($database_PESDC_MYSQL, $PESDC_MYSQL);
      $Result1 = mysql_query($insertSQL, $PESDC_MYSQL) or die(mysql_error());
     
      $insertGoTo = "confirmed.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }

    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "booking")) {
    $updateSQL = sprintf("UPDATE session SET placesbooked =%s, WHERE sessionid =%s"),
                GetSQLValueString($_POST['+1'], "int"),
                GetSQLValueString($_POST['hiddenTA'], "text"));
                       
     

      mysql_select_db($database_PESDC_MYSQL, $PESDC_MYSQL);
      $Result2 = mysql_query($updateSQL, $PESDC_MYSQL) or die(mysql_error());
    }

    mysql_select_db($database_PESDC_MYSQL, $PESDC_MYSQL);
    $query_Recordset1 = "SELECT * FROM `session`";
    $Recordset1 = mysql_query($query_Recordset1, $PESDC_MYSQL) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);

    ?>
    [/code]

    Thanks for any help with this!

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