Solved

HTML/PHP to MySQL form in Wordpress

Posted on 2016-08-18
3
56 Views
Last Modified: 2016-08-20
I have created a HTML/PHP form in wordpress, which submits the imputed data to a table in the MySQL DB.

I have about 6 fields, also a timestamp column in the DB.  I want to create the same form on another website, but have the results go into one single table on site A.

If i create a new column called "source"  how could i capture the url, the form was submitted from, and capture it in the Source column?
0
Comment
Question by:jonathan1978
3 Comments
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 250 total points
ID: 41762359
You can use the $_SERVER['REQUEST_URI'] value - it contains the URL of the page.
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 41762375
there are a few ways this can be done

add a hidden field in the form and pass it to the form processor
  • Pros: easy
  • Cons: value can be altered using debug tools

have outside forms submit to a specific url and have the processor manage the url value
  • Pros: fairly easy, harder to change vs a hidden field
  • Cons: needs a little php set up, needs a url set up for each outside form (i actually have this set up on a drupal site as a custom content type, lets me add and remove them easily and specify the url and other page level variables)

use a combination of both techniques, and an encrypted "key" value as a hidden field on the form, if this value is altered do not process the form submission, and use the "key" as an id/value reference in a second table

as a custom content type
use a custom content type with the form processor as the page template
use the meta data fields as page level variables to identify source and any other necessary variables
meta_description: customer name
meta_id:  65211351 (some customer id number) use this as the source value in your table
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 41762415
I feel like there must be some kind of backstory to this question.  It's probable that if we understand why  you want to do this we can suggest a good design pattern.

Any HTML form can submit its data to any URL.  Just change the action= attribute in the form tag, and your request data will be sent to the URL in the action= attribute.  You can use any URL, including a fully-qualified URL of another web site.  Although it's not 100% guaranteed, the combination of $_SERVER['HTTP_HOST'] and $_SERVER['REQUEST_URI'] will almost always identify the URL that the HTTP request came from.

Encrypted "keys" in hidden HTML form inputs are virtually worthless as a security measure, since a script can use cURL to read the HTML form, copy the inputs, follow the redirects, and make direct HTTP requests according to the method= and action= attributes.  So I would not depend on those kinds of things.  If you want to be sure you're getting human input, a CAPTCHA gives you the best chance of avoiding automated attacks.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now