Is there any reason why this wont work? (php/sql)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Seanie
    Member
    • Jun 2003
    • 98

    Is there any reason why this wont work? (php/sql)

    Hi,
    I had this code working perfectly, before tampering with it with the vb forum info, now it wont work.

    All I want it to do is to pull the users username and place it in the 'act' field. I've managed to do this, as you can see it on the page, but once i submit it, it only submits the 'title' field to the forum, none of the rest, is there any reason why this might be?

    PHP Code:
    <?php
       chdir
    ('/home/uraps08/public_html/promote'); 
       require_once(
    '/home/uraps08/public_html/promote/global.php');  
       
    $username $vbulletin->userinfo['username'];
    ?>

    <!-- HTML page header goes here -->
    <span class="title">My Uraps - Submit A Release</span><br />
    <?php

        
    //form not yet submitted
        //display add news form
        
    if (!$_POST['submit'])
        {
        
    ?>    
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <table width="400" border="0" cellspacing="0" cellpadding="3">
      <tr>
        <td align="right" nowrap="nowrap"><strong>Act Name:</strong></td>
        <td><input name="act" type="text" value="<?php echo $username?>" readonly size="50" maxlength="250" /></td>
      </tr>
      <tr>
        <td align="right" nowrap="nowrap"><strong>Release Title:</strong></td>
        <td><input size="50" maxlength="250" type="text" name="title" /></td>
      </tr>
      <tr>
        <td align="right" nowrap="nowrap"><strong>Release Type:</strong></td>
        <td>
        <select name="type"><br />
            <option value="" selected>Select From List</option>
            <option value="1">Single</option>
            <option value="2">Album</option>
        </select>    
        </td>
      </tr>
      <tr>
        <td align="right" nowrap="nowrap"><strong>Release Date:</strong></td>
        <td>
    <?php
        chdir
    ('/home/uraps08/public_html');
        include(
    'includes/config.php');
        include(
    'includes/functions.php');    
        
        
    //Open a connection to the database
        
    $db mysql_connect($hostname$user$pass) or die ('Error connecting to mysql');
        
    mysql_select_db($name) or die ('Error connecting to mysql');
        
        
    //generate and execute the sql query
        
    $query "SELECT * FROM $release_date_db ORDER BY date ASC";
            
        
    $result mysql_query($query)
        or die (
    "Error in query: $query. " mysql_error());

        
    //echo the drop down menu
        
    echo "<select name=\"release_date\"><br>";
        echo 
    "<option value=\"\">Select From List</option>";
        
            
    //if records are present
            
    if (mysql_num_rows($result) > 0)
            {
                
    //iterate through results
                //print title and links to edit and delete
                
    while ($row mysql_fetch_object($result))
                {
                
    ?>
                <option value="<?php echo $row->date?>"><?php echo formatDate($row->date); ?></option>
                <?php
                
    }
            
    //echo the closing tag for drop down menu
            
    }
        echo 
    "</select><br />";                    
    ?>    
        </td>
      </tr>
      <tr>
        <td align="right" nowrap="nowrap"><strong>Taken From:</strong></td>
        <td>
        <select name="taken_from">
            <option value="current">Current Album</option>
            <option value="forthcoming">Forthcoming Album</option>
            <option value="one off">One off Single</option>
        </select>    
        </td>
      </tr>
      <tr>
        <td align="right">&nbsp;</td>
        <td><input type="Submit" name="submit" value="Add Release" /></td>
      </tr>
    </table>
    </form>

    <?php
    }
    else
    {
        
    chdir('/home/uraps08/public_html');
        include(
    'includes/config.php');
        include(
    'includes/functions.php');
        
        
    //set up error list
        
    $errorList = array();
        
        
    $title $_POST['title'];
        
    $content $_POST['type'];
        
    $contact $_POST['release_date'];
        
        
    //validate text input fields
        
    if (trim($_POST['title']) == '')
        {
            
    $errorList[] = 'Invalid title';
        }
        
        if (
    trim($_POST['type']) == '')
        {
            
    $errorList[] = 'Invalid release type';
        }    
        
        if (
    trim($_POST['release_date']) == '')
        {
            
    $errorList[] = 'You have failed to select a release date.';
        }            
        
        
    //check for errors
        //if none are found...
        
    if (sizeof($errorList) == 0)
        {
            
    //Open a connection to the database
            
    $db mysql_connect($hostname$user$pass) or die ('Error connecting to mysql');
            
    mysql_select_db($name) or die ('Error connecting to mysql');    
            
    /**
    act
    title
    type
    release_date
    taken_from
    */
            
            
            //generate and execute query
            
    chdir('/home/uraps08/public_html');        
            
    $query "INSERT INTO $release_sched_db(act, title, type, release_date, taken_from) VALUES('$act', '$title', '$type', '$release_date', '$taken_from')";
            
            
    $result mysql_query($query)
            or die (
    "Error in query: $query. " mysql_error());
            
            
    //print result
            
    echo '<font size="-1">Your release has been added... <a href="releases.php">Go to the release schedule...</a>.</font>';
            
            
    //close the database connection
            
    mysql_close($db);
        }
        else
        {
            
    //errors found
            //print a list
            
    echo '<font size="-1">The following errors were found:';
            echo 
    '<br />';
            echo 
    '<ul>';
            for (
    $x=0$x<sizeof($errorList); $x++)
            {
                echo 
    "<li>$errorList[$x]";
            }
            echo 
    '</ul></font>';
        }
    }
    ?>        
    <!-- HTML page footer -->
  • Seanie
    Member
    • Jun 2003
    • 98

    #2
    anyone got any idea why this might be happening?

    Comment

    • Lynne
      Former vBulletin Support
      • Oct 2004
      • 26255

      #3
      Whoops, didn't read it completely.

      You have these lines, why don't you pull act in here?
      PHP Code:
      $title $_POST['title'];
          
      $content $_POST['type'];
          
      $contact $_POST['release_date'];
      $act $_POST['act']; 
      (Although take a look at this on how to create secure mods - http://www.vbulletin.org/forum/showthread.php?t=154411.)
      Last edited by Lynne; Thu 20 Nov '08, 10:55am.

      Please don't PM or VM me for support - I only help out in the threads.
      vBulletin Manual & vBulletin 4.0 Code Documentation (API)
      Want help modifying your vbulletin forum? Head on over to vbulletin.org
      If I post CSS and you don't know where it goes, throw it into the additional.css template.

      W3Schools &lt;- awesome site for html/css help

      Comment

      • Seanie
        Member
        • Jun 2003
        • 98

        #4
        I'm not really sure how that'll change it *has a go*

        nope still only adds the title field

        Comment

        • Seanie
          Member
          • Jun 2003
          • 98

          #5
          Is there anyway I can get this to work? It works fine when not trying to include the vb username into the act field.

          there must be a way i can include the vb username and stil be able to input the data into the sites stand alone db?


          *edit, I've managed to get the rest of the data to be stored in the db, by putting a page before this one and sending the username to the next page as a variable, however i echo it out and it appears but it doesn't show on the database

          Code:
          <input name="act" type="text" value="<?php echo "$act"; ?>" size="50" maxlength="250" />
          the name shows up, it just wont store in the db
          Last edited by Seanie; Sat 22 Nov '08, 6:07am.

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...