Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Regular Coder
    Join Date
    Sep 2005
    Posts
    153
    Thanks
    34
    Thanked 0 Times in 0 Posts

    Keep Submitted Values In A Form

    I've looked in various forums for this and tried different things but I can't seem to get it working.

    I have a form where you select a name from a drop down list. After pressing submit the page goes back to the form and I want the values to be retained instead of it saying 'Select One' again.

    My form code is:

    <php

    Code:
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <p>Enter the new track:<br />
    <textarea name="tracktitle" rows="1" cols="20">
    </textarea></p>
    	<p>Composer:
    		<select name="composerfield" size="1">
    		<option selected value="">Select One</option>
    		<option value="">---------</option>
    		<?php
      		while ($addcomposer= mysql_fetch_array($composers)) {
       		 $cid = $addcomposer['composerid'];
        		$cname = htmlspecialchars($addcomposer['composername']);
      		  echo "<option value='$cid'>$cname</option>\n";
    		  }
    		?>
    		</select></p>
    
    	<p>Album:
    		<select name="albumid" size="1">
    		<option selected value="">Select One</option>
    		<option value="">---------</option>
    		<?php
     		 while ($addalbum = mysql_fetch_array($albums)) {
       		 $aid = $addalbum['albumid'];
       		 $aname = htmlspecialchars($addalbum['albumname']);
       		 echo "<option value='$aid'>$aname</option>\n";
      		}
    		?>
    		</select></p>
    
    	<input type="submit" value="SUBMIT" />
    	</form>
    Thank you in advance

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,468
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Instead of going back to itself to process the form,

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

    Go to another script that writes a couple of cookies ... saving the form data in cookies.
    (you could also use SESSION).

    Then, that script sends it back to the form page. The transaction of that will be
    invisible to the user, but it will handle the header needed to save cookies.

    The form page (at the top) will read any cookies that are saved ... which will be
    your form values. Those can be read on any other script you have.

  • Users who have thanked mlseim for this post:

    sonofjack (12-07-2010)

  • #3
    Regular Coder
    Join Date
    Sep 2005
    Posts
    153
    Thanks
    34
    Thanked 0 Times in 0 Posts
    Thanks for the reply.

    Do you mean something along these lines?

    Code:
    <form action="formsubmit.php" method="post">
    and then in formsubmit.php

    Code:
    <?php
    
    session_start();
    $_SESSION['composerfield'] = "Saving values";
    session_write_close();
    header('Location: addtracktest.php');
    
    ?>
    Although that doesn't work.
    Any clue as to what I've missed out/done wrong?
    Thanks

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You have the right idea, just make sure you add session_start() to the top of your form script.

  • Users who have thanked Fumigator for this post:

    sonofjack (12-07-2010)

  • #5
    Regular Coder
    Join Date
    Sep 2005
    Posts
    153
    Thanks
    34
    Thanked 0 Times in 0 Posts
    Can't seem to work it out here.
    Can anyone give me a few pointers? What am I missing from my code?
    It takes me back to the form page but it hasn't submitted the original data from the form to the database.

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,468
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    More like this ...
    PHP Code:
    <?php
    session_start
    ();
    $_SESSION['composerfield'] = $_POST['composerfield'];
    header('Location: addtracktest.php');
    ?>

    You need this at the top of every script that uses SESSION ...

    <?php
    session_start();

    Also important ... It's best to have it first, without any blank lines.
    Not a big deal in your case, but it's a good habit.

    On your form page, you'll then read those variables ....

    PHP Code:
    <?php
    session_start
    ();

    // default
    $composer_field="---------";
    // read the session if it exists ...
    if(isset($_SESSION['composerfield'])){
    $composer_field=$_SESSION['composerfield'];
    }

    // Notice that I'm using a variable name $composer_field (with an underscore).
    // I don't want confusion with the form name you are using later on called "composerfield".
    ?>


    <option value="<?=$composer_field?>"><?=$composer_field?></option>

  • Users who have thanked mlseim for this post:

    sonofjack (12-07-2010)

  • #7
    Regular Coder
    Join Date
    Sep 2005
    Posts
    153
    Thanks
    34
    Thanked 0 Times in 0 Posts
    Many thanks for that.

    Haven't got it quite working yet but want to check I'm doing it right.


    My form is on addtracktest.php and I've got a file called formsubmit.php that the form posts to.

    Am I right in that this goes in formsubmit.php
    Code:
    <?php
    session_start();
    $_SESSION['composerfield'] = $_POST['composerfield'];
    header('Location: addtracktest.php');
    ?>

    Does this go just before the form on addtracktest.php, or right at the top of the file?
    Code:
    <?php
    session_start();
    
    $composer_field="---------";
    if(isset($_SESSION['composerfield'])){
    $composer_field=$_SESSION['composerfield'];
    }
    ?>
    And this goes in the form?
    Code:
    <option value="<?=$composer_field?>"><?=$composer_field?></option>
    Somewhere here?
    Code:
    <form action="formsubmit.php" method="post">
    <p>Enter the new track:<br />
    <textarea name="tracktitle" rows="1" cols="20">
    </textarea></p>
    	<p>Composer:
    		<select name="composerfield" size="1">
    		<option selected value="">Select One</option>
    
    <option value="<?=$composer_field?>"><?=$composer_field?></option> 
    
    
    		<?php
      		while ($addcomposer= mysql_fetch_array($composers)) {
       		 $cid = $addcomposer['composerid'];
        		$cname = htmlspecialchars($addcomposer['composername']);
      		  echo "<option value='$cid'>$cname</option>\n";
    		  }
    		?>
    		</select></p>
    
    	<p>Album:
    		<select name="albumid" size="1">
    		<option selected value="">Select One</option>
    		<option value="">---------</option>
    		<?php
     		 while ($addalbum = mysql_fetch_array($albums)) {
       		 $aid = $addalbum['albumid'];
       		 $aname = htmlspecialchars($addalbum['albumname']);
       		 echo "<option value='$aid'>$aname</option>\n";
      		}
    		?>
    		</select></p>
    
    	<input type="submit" value="SUBMIT" />
    	</form>


    That's what I've done and all it has done is add a "1" to my list of composers and it doesn't send anything to the database.
    I've obviously put something in the wrong place. Please could you let me know?
    Thanks

  • #8
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,468
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I'm not sure whether or not you are going to re-display the form after they submit.
    You don't have to ... but if you do, what they entered will be retained.


    This is the script with your form ...
    PHP Code:
    <?php
    session_start
    ();

    $composer_field="---------";
    if(isset(
    $_SESSION['composerfield'])){
    $composer_field=$_SESSION['composerfield'];
    }
    $album_name="---------";
    if(isset(
    $_SESSION['albumid'])){
    $album_name=$_SESSION['albumid'];
    }
    ?>


    <form action="formsubmit.php" method="post">
    <p>Enter the new track:<br />
    <textarea name="tracktitle" rows="1" cols="20">
    </textarea></p>
        <p>Composer:
            <select name="composerfield" size="1">
    <?php
    if(isset($_SESSION['composerfield'])){
    echo
    "<option value=\"$composer_field\">$composer_field</option>";
    }
    else{
    echo
    "<option selected value=\"\">Select One</option>";
    }

              while (
    $addcomposermysql_fetch_array($composers)) {
                
    $cid $addcomposer['composerid'];
                
    $cname htmlspecialchars($addcomposer['composername']);
                echo 
    "<option value='$cid'>$cname</option>\n";
              }
            
    ?>
            </select></p>

        <p>Album:
            <select name="albumid" size="1">
    <?php
    if(isset($_SESSION['albumid'])){
    echo
    "<option value=\"$album_name\">$album_name</option>";
    }
    else{
    echo
    "<option selected value=\"\">Select One</option>";
    }
              while (
    $addalbum mysql_fetch_array($albums)) {
                
    $aid $addalbum['albumid'];
                
    $aname htmlspecialchars($addalbum['albumname']);
                echo 
    "<option value='$aid'>$aname</option>\n";
              }
            
    ?>
            </select></p>

        <input type="submit" value="SUBMIT" />
        </form>

    At the top of "formsubmit.php":
    PHP Code:
    <?php
    session_start
    ();
    $_SESSION['composerfield'] = $_POST['composerfield'];
    $_SESSION['albumid'] = $_POST['albumid'];

    //  You are going to have more script below here ? ...
    //  So you don't need to redirect anywhere.
    //header('Location: addtracktest.php');

    // The rest of your form submit script here if you have more ...
    // perhaps you are writing their data into a database?
    // If there is a problem, or you need to go back to the form,
    // the user will retain the information they already put in.

    // return back if you need to:
    //header('Location: addtracktest.php');


    ?>

  • Users who have thanked mlseim for this post:

    sonofjack (12-07-2010)

  • #9
    Regular Coder
    Join Date
    Sep 2005
    Posts
    153
    Thanks
    34
    Thanked 0 Times in 0 Posts
    Many thanks again.

    Yes I can see what it's doing. However I've been trying to tweak to work exactly how I want. Can't seem to get it right.

    It isn't submitting the data to the database so do I need to have this bit that comes after the form on my addtracktest page..

    Code:
    if (isset($_POST['tracktitle'])) :
    	$tracktitle = $_POST['tracktitle'];
    	$addcomposer = $_POST ['composerfield'];
    	$addalbum = $_POST ['albumid'];
    		
    if ($composers ==") { exit ('<p>Choose a composer</p>'); }
    if ($albums ==") { exit ('<p>Choose an album</p>'); }
    
    $sql = "INSERT IGNORE INTO tracks (trackid, tracktitle, albumid, composerid) VALUES ('$trackid', '$tracktitle', '$addalbum', '$addcomposer')"; 
    
    if (mysql_query($sql)) {echo "Track added";}
    else {echo "DEBUG SQL: " . $sql . "<p>Error adding track " . mysql_error() . "</p>";}
    
    endif;
    ....on my formsubmit.php page? Followed by a return the form?

    Also after I submit it seems to be displaying the ID number in the composer field rather than the name which is also in the dropdown list. Similarly with the album id.
    It needs to retain the album and composer that was submitted and display the name ready for another track submission with those values. I want the user to keep adding tracks by the same composer and album until they want to change. And the other fields which I will add later once I get this all working well.

    It's nearly there...

  • #10
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,468
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Post all of the scripts you have ...
    It's too hard to figure this out by scrolling back and forth between posts.

  • #11
    Regular Coder
    Join Date
    Sep 2005
    Posts
    153
    Thanks
    34
    Thanked 0 Times in 0 Posts
    Good idea

    addtracktest.php

    Code:
    <?php
    session_start();
    
    $composer_field="---------";
    if(isset($_SESSION['composerfield'])){
    $composer_field=$_SESSION['composerfield'];
    }
    $album_name="---------";
    if(isset($_SESSION['albumid'])){
    $album_name=$_SESSION['albumid'];
    }
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <title>New Tracks</title>
    <meta http-equiv="content-type"
        content="text/html; charset=iso-8859-1" />
    <style>
    body {font-family: arial; font-size: 12px;}
    </style>
    </head>
    <body>
    
    <?php include('connect.php'); ?>
    
    <?php
    
      $composers = @mysql_query('SELECT composerid, composername FROM composers');
      if (!$composers) {
        exit('<p>Unable to obtain composer list from the database.</p>');  }
    
      $albums = @mysql_query('SELECT albumid, albumname FROM albums');
      if (!$albums) {
        exit('<p>Unable to obtain album list from the database.</p>');  }
    ?>
    
    
    <?php
    
    
    
    //If track has been deleted remove from database.
    
    
    if (isset($_GET['deletetrack'])) {
    
    $id = $_GET['deletetrack'];
    
    $sql = "DELETE FROM tracks 
    WHERE trackid='$id'";
    
    if (@mysql_query($sql)) {
    echo '<p>This listings has been deleted.</p>';
    } 
    else {
    echo '<p>Error deleting listings: ' .
    mysql_error() . '</p>';
    }
    }
    
    ?>
    
    // Form
    <form action="formsubmit.php" method="post">
    <p>Enter the new track:<br />
    <textarea name="tracktitle" rows="1" cols="20">
    </textarea></p>
    	<p>Composer:
    		<select name="composerfield" size="1">
    	
    <?php
    if(isset($_SESSION['composerfield'])){
    echo"<option value=\"$composer_field\">$composer_field</option>";
    }
    else{
    echo"<option selected value=\"\">Select One</option>";
    }
    
              while ($addcomposer= mysql_fetch_array($composers)) {
                $cid = $addcomposer['composerid'];
                $cname = htmlspecialchars($addcomposer['composername']);
                echo "<option value='$cid'>$cname</option>\n";
              }
            ?>
            </select></p>
    
        <p>Album:
            <select name="albumid" size="1">
    <?php
    if(isset($_SESSION['albumid'])){
    echo"<option value=\"$album_name\">$album_name</option>";
    }
    else{
    echo"<option selected value=\"\">Select One</option>";
    }
              while ($addalbum = mysql_fetch_array($albums)) {
                $aid = $addalbum['albumid'];
                $aname = htmlspecialchars($addalbum['albumname']);
                echo "<option value='$aid'>$aname</option>\n";
              }
            ?>
            </select></p>
    
        <input type="submit" value="SUBMIT" />
        </form> 
    
    <?php
    if (isset($_POST['tracktitle'])) :
    
    	$tracktitle = $_POST['tracktitle'];
    	$addcomposer = $_POST ['composerfield'];
    	$addalbum = $_POST ['albumid'];
    		
    if ($composers ==") { exit ('<p>Choose a composer</p>'); }
    if ($albums ==") { exit ('<p>Choose an album</p>'); }
    
    $sql = "INSERT IGNORE INTO tracks (trackid, tracktitle, albumid, composerid) VALUES ('$trackid', '$tracktitle', '$addalbum', '$addcomposer')"; 
    
    if (mysql_query($sql)) {echo "Track added";}
    else {echo "DEBUG SQL: " . $sql . "<p>Error adding track " . mysql_error() . "</p>";}
    
    
    endif; 
    
    ?>
    
    
    
    <hr>
    <p>Tracks</p>
    
    <?php 
    $sql = 'SELECT tracks.trackid, tracks.tracktitle, composers.composername, albums.albumname FROM tracks, composers, albums WHERE 
    
    albums.albumid = tracks.albumid AND composers.composerid = tracks.composerid ORDER BY tracks.tracktitle ASC';
    ?>
    
    <table>
    <tr><th align=left>Track Title</th>
    <th align=left>Composer</th>
    <th align=left>Album</th></tr>
    
    <?php
    
    $tracks = @mysql_query( $sql );
    
    if (!$tracks) {
      echo '</table>';
      exit('<p>Error retrieving tracks from database!<br />'.
          'Error: ' . mysql_error() . '</p>');
    }
    
    while ($track = mysql_fetch_array($tracks)) {
      echo "<tr valign='top'>\n";
      $id = $track['trackid'];
      $tracktitle = htmlspecialchars($track['tracktitle']);
      $composername = htmlspecialchars($track['composername']);
      $albumtitle = htmlspecialchars($track['albumname']);
     
      echo "<td width=150>$tracktitle</td>";
      echo "<td width=150>$composername</td>";
      echo "<td width=300>$albumtitle</td>";
      echo "<td><a href='edittrack.php?id=$id'>Edit</a> | ";
      echo "<a href=" . $_SERVER['PHP_SELF'] .  "?deletetrack=$id>Delete</a></td>\n";
      echo "</tr>\n";  
    
    }
    
    ?>
    
    </table>
    
    </body>
    </html>
    formsubmit.php

    Code:
    <?php
    session_start();
    $_SESSION['composerfield'] = $_POST['composerfield'];
    $_SESSION['albumid'] = $_POST['albumid'];
    
    //  You are going to have more script below here ? ...
    //  So you don't need to redirect anywhere.
    //header('Location: addtracktest.php');
    
    
    // The rest of your form submit script here if you have more ...
    // perhaps you are writing their data into a database?
    // If there is a problem, or you need to go back to the form,
    // the user will retain the information they already put in.
    
    // return back if you need to:
    header('Location: addtracktest.php');
    
    ?>

    Many thanks.

  • #12
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Also after I submit it seems to be displaying the ID number in the composer field rather than the name which is also in the dropdown list
    Yes, that's how select and option elements work. The value of the "value" attribute is what gets sent through the form submit. Whatever is between <option> and </option> is merely for display purposes, it does not go anywhere. If you need that string value, you'll have to run a query and select it again from the database using the selected ID.

  • #13
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,468
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Try these two scripts ....

    addtracktest.php
    PHP Code:
    <?php
    session_start
    ();

    $composer_field="---------";
    if(isset(
    $_SESSION['composerfield'])){
    $composer_field=$_SESSION['composerfield'];
    }
    $album_id="---------";
    if(isset(
    $_SESSION['albumid'])){
    $album_id=$_SESSION['albumid'];
    }

    // messages from formsubmit
    if(isset($_GET['mess']){
    $mess=$_GET['mess'];
    }
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <title>New Tracks</title>
    <meta http-equiv="content-type"
        content="text/html; charset=iso-8859-1" />
    <style>
    body {font-family: arial; font-size: 12px;}
    </style>
    </head>
    <body>

    <?php include('connect.php'); ?>

    <?php

      $composers 
    = @mysql_query('SELECT composerid, composername FROM composers');
      if (!
    $composers) {
        exit(
    '<p>Unable to obtain composer list from the database.</p>');  }

      
    $albums = @mysql_query('SELECT albumid, albumname FROM albums');
      if (!
    $albums) {
        exit(
    '<p>Unable to obtain album list from the database.</p>');  }
    ?>

    <!-- Display any messages from formsubmit -->
    <b><?=$mess?></b><br />

    <form action="formsubmit.php" method="post">
    <p>Enter the new track:<br />
    <textarea name="tracktitle" rows="1" cols="20">
    </textarea></p>
        <p>Composer:
            <select name="composerfield" size="1">
        
    <?php
    if(isset($_SESSION['composerfield'])){
       while (
    $addcomposermysql_fetch_array($composers)) {
       
    $cid $addcomposer['composerid'];
          if(
    $cid == $composer_field){
          
    $cname htmlspecialchars($addcomposer['composername']);
          }
       echo
    "<option value=\"$composer_field\">$cname</option>";
       }
    }
    else{
    echo
    "<option selected value=\"\">Select One</option>";
    }
              while (
    $addcomposermysql_fetch_array($composers)) {
                
    $cid $addcomposer['composerid'];
                
    $cname htmlspecialchars($addcomposer['composername']);
                echo 
    "<option value='$cid'>$cname</option>\n";
              }
            
    ?>
            </select></p>

        <p>Album:
            <select name="albumid" size="1">
    <?php
    if(isset($_SESSION['albumid'])){
       while (
    $addalbummysql_fetch_array($albums)) {
       
    $aid $addalbum['albumid'];
          if(
    $aid == $album_id){
          
    $aname htmlspecialchars($addcomposer['albumname']);
          }
       echo
    "<option value=\"$album_name\">$aname</option>";
       }
    }
    else{
    echo
    "<option selected value=\"\">Select One</option>";
    }
              while (
    $addalbum mysql_fetch_array($albums)) {
                
    $aid $addalbum['albumid'];
                
    $aname htmlspecialchars($addalbum['albumname']);
                echo 
    "<option value='$aid'>$aname</option>\n";
              }
            
    ?>
            </select></p>

        <input type="submit" value="SUBMIT" />
        </form> 
    <hr>
    <p>Tracks</p>

    <?php 
    $sql 
    'SELECT tracks.trackid, tracks.tracktitle, composers.composername, albums.albumname FROM tracks, composers, albums WHERE 

    albums.albumid = tracks.albumid AND composers.composerid = tracks.composerid ORDER BY tracks.tracktitle ASC'
    ;
    ?>

    <table>
    <tr><th align=left>Track Title</th>
    <th align=left>Composer</th>
    <th align=left>Album</th></tr>

    <?php

    $tracks 
    = @mysql_query$sql );

    if (!
    $tracks) {
      echo 
    '</table>';
      exit(
    '<p>Error retrieving tracks from database!<br />'.
          
    'Error: ' mysql_error() . '</p>');
    }

    while (
    $track mysql_fetch_array($tracks)) {
      echo 
    "<tr valign='top'>\n";
      
    $id $track['trackid'];
      
    $tracktitle htmlspecialchars($track['tracktitle']);
      
    $composername htmlspecialchars($track['composername']);
      
    $albumtitle htmlspecialchars($track['albumname']);
     
      echo 
    "<td width=150>$tracktitle</td>";
      echo 
    "<td width=150>$composername</td>";
      echo 
    "<td width=300>$albumtitle</td>";
      echo 
    "<td><a href='edittrack.php?id=$id'>Edit</a> | ";
      echo 
    "<a href='formsubmit.php?deletetrack=$id'>Delete</a></td>\n";
      echo 
    "</tr>\n";  

    }

    ?>

    </table>

    </body>
    </html>

    formsubmit.php
    PHP Code:
    <?php
    session_start
    ();
    if(isset(
    $_POST['composerfield'])){
    $_SESSION['composerfield'] = $_POST['composerfield'];
    }
    if(isset(
    $_POST['albumid'])){
    $_SESSION['albumid'] = $_POST['albumid'];
    }

    if (isset(
    $_POST['tracktitle'])){

        
    $tracktitle $_POST['tracktitle'];
        
    $addcomposer $_POST ['composerfield'];
        
    $addalbum $_POST ['albumid'];
            
    if (
    $composers ==") { $mess="<p>Choose a composer</p>"; }
    if ($albums =="
    ) { $mess="<p>Choose an album</p>"; }

    $sql "INSERT IGNORE INTO tracks (trackid, tracktitle, albumid, composerid) VALUES ('$trackid', '$tracktitle', '$addalbum', '$addcomposer')"

    if (
    mysql_query($sql)) {$mess"Track added";}
    else {echo 
    "DEBUG SQL: " $sql "<p>Error adding track " mysql_error() . "</p>";}

    }

    //If track has been deleted remove from database.
    if (isset($_GET['deletetrack'])) {

    $id $_GET['deletetrack'];

    $sql "DELETE FROM tracks 
    WHERE trackid='$id'"
    ;

    if (@
    mysql_query($sql)) {
    $mess="This listings has been deleted.</p>";

    else {
    $mess="Error deleting listings: " .mysql_error(). "</p>";
    }
    }

    // return back:
    header('Location: addtracktest.php?mess=$mess');

    ?>
    Last edited by mlseim; 12-07-2010 at 05:16 PM.

  • Users who have thanked mlseim for this post:

    sonofjack (12-07-2010)

  • #14
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,468
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    EDIT:

    I just made a couple of changes to the two scripts above.
    Re-copy them please ...


    .

  • Users who have thanked mlseim for this post:

    sonofjack (12-07-2010)

  • #15
    Regular Coder
    Join Date
    Sep 2005
    Posts
    153
    Thanks
    34
    Thanked 0 Times in 0 Posts
    Thanks again for that.
    I'm just studying the code to work out what is going where.

    At present the composer field is just showing the one, and the album field isn't showing any data. And when I submit, I get the message:

    Parse error: syntax error, unexpected '>' in /home/dancesounds/dancesounds.co.uk/phpsearch/formsubmit.php on line 16

    Which seems to point to:

    Code:
    if ($composers ==") { $mess="<p>Choose a composer</p>"; }
    if ($albums ==") { $mess="<p>Choose an album</p>"; }
    I tried changing it to....

    Code:
    if ($composers ==") { $mess='<p>Choose a composer</p>'; }
    if ($albums ==") { $mess='<p>Choose an album</p>'; }
    ...to see if the " and ' was causing any confusion.
    Then after submitting the form it takes me back to the addtracktest.php page with

    $mess

    displayed at the top of the page.

    I also noticed that

    Code:
    echo"<option value=\"$album_name\">$aname</option>";
    should probably have been

    Code:
    echo"<option value=\"$album_id\">$aname</option>";
    Though on changing it it hasn't made a difference to displaying the album titles.

    Thought it was there but I can't work out which bit isn't working.
    Thanks again for looking into it.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •