Solved

HTML/PHP to MySQL form in Wordpress

Posted on 2016-08-18
3
108 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:Jon Imms
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 58

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 110

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
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…

631 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