Solved

HTML/PHP to MySQL form in Wordpress

Posted on 2016-08-18
3
67 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 52

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

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

Suggested Solutions

Title # Comments Views Activity
Problem with Simple PHP/mySQL Query 3 51
WordPress TK Title 8 23
hiding/removing php extension - best practice 4 24
Problem sending file attachments 8 22
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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 reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…

932 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

15 Experts available now in Live!

Get 1:1 Help Now