jamesxg1 Posted February 5, 2009 Share Posted February 5, 2009 <?php session_start(); require("../db/db.php"); //include database file require("../db/config.php"); //include configuration file require("../db/util.php"); isloggedin(); accessneeded("C"); ?> <?php $userrep = $_GET['username']; $usern = $_SESSION['username']; ?> <?php if(isset($_POST['submit'])) { $reporteduser = strip_tags(mysql_real_escape_string($_POST['reporteduser'])); $reporter = strip_tags(mysql_real_escape_string($_POST['reporter'])); $report = strip_tags(mysql_real_escape_string($_POST['report'])); $sql = "INSERT INTO reports (reporteduser, reporter, report) VALUES('$userrep', '$usern', '$report')"; mysql_query($sql) or die(mysql_error()); print ("<P ALIGN=CENTER>The user $userr has been reported to Admin.<br>Please Return Back To The <a href='../main/index.php'>Home Page</a></P>"); exit; } ?> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <P ALIGN=CENTER><center> <h3>You Are Reporting An Offence On: <?php print $userrep ?></h3> <textarea rows="5" cols="40" name="report" id="$report">The report you want to make about <?php print $userrep ?> goes here.</textarea><br /> <br> <INPUT type="hidden" name="userrep" id="$userrep" value="<?php print $userrep ?>"><br> <input type="submit" name="submit" value="Submit"> </form></P></center> it inputs everything except $userrep :S Link to comment https://forums.phpfreaks.com/topic/143928-solved-wont-input-into-mysql/ Share on other sites More sharing options...
rhodesa Posted February 5, 2009 Share Posted February 5, 2009 i assume it's a GET variable (in the URL) when the page first loads, but you then make it a POST variable by putting it into a hidden form element. update your section of code to be this: <?php if(isset($_POST['submit'])) { $reporteduser = strip_tags(mysql_real_escape_string($_POST['reporteduser'])); $reporter = strip_tags(mysql_real_escape_string($_POST['reporter'])); $report = strip_tags(mysql_real_escape_string($_POST['report'])); $userrep = strip_tags(mysql_real_escape_string($_POST['userrep'])); $sql = "INSERT INTO reports (reporteduser, reporter, report) VALUES('$userrep', '$usern', '$report')"; mysql_query($sql) or die(mysql_error()); print ("<P ALIGN=CENTER>The user $userr has been reported to Admin.<br>Please Return Back To The <a href='../main/index.php'>Home Page</a></P>"); exit; } ?> Link to comment https://forums.phpfreaks.com/topic/143928-solved-wont-input-into-mysql/#findComment-755243 Share on other sites More sharing options...
jamesxg1 Posted February 5, 2009 Author Share Posted February 5, 2009 i assume it's a GET variable (in the URL) when the page first loads, but you then make it a POST variable by putting it into a hidden form element. update your section of code to be this: <?php if(isset($_POST['submit'])) { $reporteduser = strip_tags(mysql_real_escape_string($_POST['reporteduser'])); $reporter = strip_tags(mysql_real_escape_string($_POST['reporter'])); $report = strip_tags(mysql_real_escape_string($_POST['report'])); $userrep = strip_tags(mysql_real_escape_string($_POST['userrep'])); $sql = "INSERT INTO reports (reporteduser, reporter, report) VALUES('$userrep', '$usern', '$report')"; mysql_query($sql) or die(mysql_error()); print ("<P ALIGN=CENTER>The user $userr has been reported to Admin.<br>Please Return Back To The <a href='../main/index.php'>Home Page</a></P>"); exit; } ?> Worked thanks mate Ace! Link to comment https://forums.phpfreaks.com/topic/143928-solved-wont-input-into-mysql/#findComment-755252 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.