How can I populate a Form field and hide it?

In this PHP script I’m using, I’d like to modify a Form by populating a Form field, and hiding it, so that the field is always filled-in with information that I want it to be. Here is the current field in the Form:

     <li style="width:700px; text-align:center;"><span class="font5_12">[var.lang_step] 1: [var.lang_select_photo_album]</span></li>

      <li style="width:240px; text-align:right;"><strong>[var.lang_your_albums]:</strong></li>

      <li style="width:400px; text-align:left;"><select name="album_id" size="1" tabindex="1" class="upload-video-form-input">[var.albums_all;htmlconv=no]</select></li>

Any help will be appreciated.

You can use <input type="hidden" name="..." value="..."> for fields you want to contain hidden values

Thanks for your reply.

So, to hide the Form field example I provided and your instruction it would be:

<input type="hidden" name="album_id" value="...">

Correct? What would the value be?

Any additional guidance is appreciated.

Whatever you want it to be.

Of course, thanks.

However, this doesn’t work:

<input type="hidden" name="album_id" value="Album0">

When I proceed with the Form, the Form error message states: “Error - Please Select an album”

Any additional help will be appreciated.

There is nothing wrong with that line alone.
But to identify the problem it needs to be seen in context with the form and processor that is creating the error.

Thank you for your reply.
I’m attaching the image_uploader file.
If you could be so kind as to take a peek at it to determine how I can remove that Error, I would grealy appreciate it.

image_uploader1.php (20.7 KB)

TBH I would remove that entire file and replace it.

It is out-of-date and uses the mysql extension
It uses @ error suppression which is often a sign of poor code.

Yes, I realize it isn’t the best code, but it would be way more work to re-write the script. Any help will be appreciated.

You effectively have no choice but to rewrite it to use current PHP.

PHP has two ways to interact with mySQL databases - you can either use mySQLi calls or PDO calls. Both of these were introduced in July 2004. The mysql_ extension was flagged for removal from PHP back in 2012 and was actually removed in 2015. It is no longer a part of PHP and so any code that uses it will break as soon as you upgrade to the latest version of PHP (7). The last version of PHP that still supports it (5.6) is only being fully maintained for another month after which it will only get security patches. The version of PHP before that (5.5) will no longer receive even security patches after next month. As you haven’t upgraded the code during the over three years that was provided for doing so it needs to be your highest priority now given the limited time that remains before the old versions of PHP that still support it are receiving security patches.

Aside from the issue of database access which will need to be dealt with, I suspect one of the issues you have is this. In your form input above you have

<input type="hidden" name="album_id" value="Album0">

But in your php code, you have:

$album_id = (int) mysql_real_escape_string( $_POST['album_id'] );

So that implies that the album_id field must be an integer (which would make sense), yet you set it to “Album0”. I must admit I don’t know how php deals with attempting to cast a text string to a number.


Thanks for all your replies. Much appreciated.
What are the consequences of not updating the script to work with PHP7?
What would it take to upgrade this type of script? A complete rewrite? Or a modification?
So, with PHP7 the script can no longer use the mySQL database?

With PHP7 the script will not work.

The bits to do with mysql will have to change, the rest of it can remain.

You can, but it is accessed in a different way, using either mysqli or PDO.
You should look at learning PDO.
When I made the switch from mysql I went for mysqli, thinking it would be more similar and an easier transition.
But when I later tried PDO, I found it was not that hard to learn and I much prefer it to mysql or mysqli.

Thanks for your reply.

“The bits to do with mysql will have to change, the rest of it can remain”, that’s encouraging.

However, instead of “What are the consequences of not updating the script to work with PHP7?”,
what i meant to ask was What are the consequences of staying with PHP 5+ ?

lol It was the same with me. With my deeply ingrained procedural mindset I feared OOP would be more complex.
Perhaps it is more complex to write good OOP code, using it is much easier.

At first they are likely to stop getting anything but critical security patches.
After that not upgrading will result in increased security risk.
More than likely, at that time shared hosts will remove the dead versions to protect their customers.

As felgall has already pointed out previously

Actually, PHP5.6 has another 6 month’s active support.

In a general sense none.

until someone finds a significant security hole and manages to trash all the servers still using it.

Yes, it was originally scheduled to end this month but they have extended the support dates for 5.6 as it is the very last of the PHP 5 versions and so they are giving the tail enders a few extra months to finish upgrading their code. I’d remembered the extended patch support but forgot about the extra six months full support.

1 Like