Solved

HTML/PHP to MySQL form in Wordpress

Posted on 2016-08-18
3
86 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 55

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 109

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The purpose of this video is to demonstrate how to Import and export files in WordPress. 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 : Click on Too…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

828 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