Assuming you only copy/pasted the relevant code and your form includes <form method="POST">
if(isset($_POST['filename'])){
$filename = $_POST['filename'];
}
if(isset($filename)){
echo $filename;
}
If _POST is not set the filename variable won’t be either in the above example.
An alternative way:
$filename = false;
if(isset($_POST['filename'])){
$filename = $_POST['filename'];
}
echo $filename; //guarenteed to be set so isset not needed
In this example filename is set regardless of the situation with _POST. This should demonstrate the use of isset nicely.
More information here: http://php.net/manual/en/function.isset.php
Related Posts:
- How to read if a checkbox is checked in PHP?
- PHP $_POST not working?
- POST an array from an HTML form without javascript
- add_filter the_content str_replace after shortcode
- Genesis – Customize search form
- How to insert PHP code in a WordPress Post
- Has anyone tried putting PHP ActiveRecord on WordPress?
- Handling error states with admin_post
- Creating wordpress user registration form
- submit the form to same page
- Ajax form submit within a Post Metabox
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- Upload Image in a WordPress page using PHP
- Custom Form Processing Issue
- My form action url is being prepended with a directory that does not exists
- Custom profile field with birthday. Troubles with
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- Custom search results page not working with empty search
- Post + form + action + results on the same page
- How to pre populate a form field with a link of a current user’s author profile?
- Why Won’t My Inputs in a form with a Get method work together?
- Input data from email form not going to JSON file
- How to get the value of input hidden html from text editor to custom page template?
- Contact form won’t submit
- wp_mail file attachment not being placed in upload folder?
- How to show a ‘correct’ message after submit a form?
- Form Security: nonce vs. jQuery
- Trying do build a contact form
- “operation successful” message
- User register hook is not working in woocomerce register form
- How to put a form with php code into a variable or shortcode?
- Can a page contain php code?
- How to send form data from WordPress (Meta Box) to an OData service?
- WordPress shortcode returns the data before
- Form Submission Not Working In Custom Theme
- Capture form data in one function and use it in another function (same file)
- Why does my user not get added to the database on custom registration?
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- How to add post meta in while loop?
- How to set cookies
- PHP Contact form
- Get wp_current_user_id using PHP and MySQL
- PHP- Why is my contact form keep showing it is invalid? [closed]
- Simple php in wordpress widget [closed]
- Pass important values server-side when processing form
- WPDB secure custom form
- Adding data to custom wordpress database table
- Make a page (url) not cacheable [closed]
- Display multi-select box choices in a bullet list [closed]
- Custom forms with HTML
- Testing a Form’s Zipcode Field with Regular Expressions to Determine WordPress Page Behaviour
- Using Ajax to submit a form, and run a SQL Select query based on user input from the form
- $_POST returning empty values
- Trying to update Woocommerce meta values
- How to send custom form submissions to WordPress Database?
- Custom PHP form needs refresh to load page correctly
- I want it to detect the duplicate comment and give a warning on the same page
- PHP multiple forms, same page, isset($_POST[]) not working?
- “Class Not Found” in HTML Form Target PHP File that contains the class
- How to change this ajax function to submit to the default wordpress content area instead of the custom field ‘seller notes’?
- Confuse between forms and tables
- wordpress contact form messages not sending although it saying they were sent successfully with this php code
- Using a PHP form, get the page title or any other element in the sent e-mail
- How do I stop my form from adding code to current page URL instead of re-directing. Been stuck for days
- custom search query database in child theme
- Creating a WordPress addon for ContactForm7 submission (.XML file export)
- Using transients to store form notifications
- Insert data from form to database
- not able to access $_POST on backend profile update
- Custom Plugin Develoment, Form Action
- wordpress form action page not found
- Trouble with checked() for array of multiple checkboxes
- Custom HTML form using PHP – help with ajax/username validation
- Form direction to .php on localhost
- Form not working as it should in WordPress, but in a normal HTML site it does
- Ajax call URL 404’ing when pushed to staging server
- Update only some custom user fields
- Passed variable gets undefined variable error on insert on next page
- Accessing values entered via form – try again
- Nonce fail after second submit attempt
- How to set up an auto delete post?
- Dynamic form variables for post meta
- Trying to display user meta by “name” – not by “ID”
- Headers for Contact Form are wrong
- Using Nonce for my Form
- Trouble using wordpress functions in a pop-up modal form
- custom contact form no longer working (because of 3.2?)
- Correct Syntax for uploading files to custom directory in WordPress
- How to pass username into form that sends data to database
- HOW TO Insert Existing PHP Code to WOrdPress
- php inside HTML via shortcode? [closed]
- Where to put include php file?
- Redirect loop upon installation of my plugin
- Field validation strlen works in php7.4 fails 8.1 [closed]
- Embed PHP script into WP – what is the best way
- Preventing script injections in HTML form
- Can’t insert into a database wordpress
- Help with commenting system
- How to create a form that display license key (and email it to user) after the user enter their email and 10 digit code?
- Automatically populating a date parameter within a shortcode