Solved

HTML/PHP to MySQL form in Wordpress

Posted on 2016-08-18
3
79 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 54

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

809 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