So, I have a database which is now working correctly, storing the values from the google api and 2 others that are entered at the same time. However Id like to add some more data to the database in the form of user details (name, email address, that sort of thing). Another lecturer has said that using the same kind of process that I already am using, I should be able to store this in the memory.
The page etc is here:
www.zpyder.co.uk/tess/mapping/db/welcome.phpThe problem is that the code I am trying doesnt break the system, but also doesnt do anything. IE: its still saving the google data but is leaving the email address field blank. See below for the code...
This is the welcome page as a test run, I want the user to enter an email address which will be used as their user ID. The email address field is called email and is a 50 charcter varchar in the database.
This is the userprocess.php file. I couldnt figure out how to get it to load the mapping page after sending the form data above apart from using the header value. I dont know if this is the correct way/if this is responsible for the issue.
header(Location: test.html);
//connect to dbase
require("dbconn.php");
//obtain email field
$email=$_POST[email];
?>
The mapping page has grown hugely since the last thread/set of questions. I think it can probably be pretty much ignored here.
Thank you for taking part in section 4 of the Ecosystem services
questionnaire.
The map below can be zoomed in and out using the controls on the left, and it
is possible to move around the map by clicking and dragging.
You may place up to 6 markers on areas which you value for each of 3 value
types (Recreation, Aesthetics, or Culture).
To place a marker simply click on an area of value within the red boundary, and a
marker will appear. This can be moved by clicking and dragging the icon.
When placing a marker you are required to enter the Value type in the first
text box, followed by the score, or how much you value that area.
Once you are happy with the information that has been entered, click
submit.
A marker will not be saved until submit is
pressed. If you make a mistake, refresh the page before clicking submit.
Please ensure that for each value type the total score of the combined
markers is 100.
The 2 other php files that are called are below. I think the problem is somewhere in the transfer of the $email value between the files or something?
myserver.php
//lat&lng are decimal numbers, value is text, score is an integer 0-100
$lat = $_REQUEST["lat"];
$lng = $_REQUEST["lng"];
$values = $_REQUEST["values"];
$score = $_REQUEST["score"];
$email = $_POST["email"];
//Connection to database
require("dbconn.php");
//Creates sql session connection routine using the above values
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (Error connecting to mysql);
//Selects the database and then runs the session connection routine
mysql_select_db($dbname,$conn);
//Defines the data to insert into the data table
$sqlinsert = "INSERT INTO zpyder_tess.google (lat,lng,value,score,email) VALUES($lat,$lng,$values,$score,$email)";
//Runs the insert routine
mysql_query($sqlinsert,$conn);
?>
genxml.php
require("dbconnxml.php");
// Start XML file, create parent node
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$parnode = $dom->appendChild($node);
// Opens a connection to a MySQL server
$connection = mysql_connect($dbhost, $dbuser, $dbpass) or die (Error connecting to mysql);
// Set the active MySQL database
$db_selected = mysql_select_db($dbname, $connection);
if (!$db_selected) {
die (Can\t use db : . mysql_error());
}
// Select all the rows in the markers table
$query = "SELECT * FROM google WHERE 1";
$result = mysql_query($query);
if (!$result) {
die(Invalid query: . mysql_error());
}
// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("lat", $row[lat]);
$newnode->setAttribute("lng", $row[lng]);
$newnode->setAttribute("value", $row[value]);
$newnode->setAttribute("score", $row[score]);
$newnode->setAttribute("email", $row[email]);
}
echo $dom->saveXML();
?>