Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7668649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:24:54+00:00 2026-05-31T15:24:54+00:00

I’m sure i’ve badly written this. I have a simple form which you enters

  • 0

I’m sure i’ve badly written this. I have a simple form which you enters bits into, which sends the info onto a process page and inserts a row into a table on the database. My problem is that the insert part works fine. But my template class within the page or anything else is shown. Just a blank page. Its driving me nuts.

The function

     Public function UpdateReason($reason, $bundlereference) {
      error_reporting(E_ALL ^ E_NOTICE);
      $db_selected = mysql_select_db(DB_DATABASE_NAME, $this->conn);

     if (!$db_selected) {
     die("Can't use db : " . mysql_error());
      }

     $_reason = mysql_real_escape_string($reason,$this->conn);
     $_bundlereference = mysql_real_escape_string($bundlereference,$this->conn);

     $sql = "UPDATE `ArchiveBundle`
        SET `Issue` = '" . $_reason . "'
        WHERE `BundleReference` = '" . $_bundlereference . "'";

    mysql_query($sql, $this->conn);

     die(mysql_error());
     exit;
  }

The form

         <table>
                    <form method='post' action='addissue.php'>
                    <p>Reason: <input type='text' name='reason' /></p><br/>
                    <p><input type='hidden' name='bundlereference' id='Username'  
          value='" . $x['Reference'] . "' /></p>
                    <input type='submit' name ='add'/>
                </form>
            </table>

The process page

    <?php

// First of all initialise the user and check for permissions
require_once "/var/www/users/user.php";
$user = new CHUser(2);


// Initialise the template
require_once "/var/www/template/template.php";
$template = new CHTemplate();

// And create a cid object
    require_once "/var/www/Testing/DisplayWIPOnLocation.php";
$BundleProgress= new CHWIPProgress();

    $reason = $_POST['reason'];
    $reference = $_POST['bundlereference'];



    $issue = $BundleProgress->UpdateReason($_POST['reason'],$_POST['bundlereference']);
    Print "Your information has been successfully added to the database."; 


  $template->SetTag("content", $content);
  echo $template->Display();


    ?>

I also want to know/learn what the best practices are for forms in php

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:24:55+00:00Added an answer on May 31, 2026 at 3:24 pm

    The reason you aren’t getting output is the following two lines. This is killing your script in place. Just remove these.

     die(mysql_error());
     exit;
    

    Overall, it’s not terrible. You’re using objects, and you’re sanitizing your user input before inserting into the db. I do have a couple suggestions.

    • Don’t use die() in a production script. Handle errors and exceptions properly.
    • Look into prepared statements (PDO) or stored procedures for mysql.
    • Instead of the print "Your information has been added..." line, can you create a field in your template and pass in that value through your template class?
    • You set $reason and $reference then pass in the value from $_POST, making those unused variables. Maybe this is just due to testing code though?
    • Depending on your needs, you may want to consider checking that the data the form has received is valid before running an update query. What if $reason or $bundlereference aren’t valid values?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a text area in my form which accepts all possible characters from
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.