Note that there are some explanatory texts on larger screens.

plurals
  1. POBetter Way to Post Info in DB?
    primarykey
    data
    text
    <p>Currently, my code on the HTML side looks like this:</p> <pre><code>&lt;form action="newstory.php" method="post"&gt; &lt;input type="hidden" name="author" value="&lt;?php echo $loggedInUser-&gt;display_username; ?&gt;" /&gt; &lt;input type="hidden" name="userid" value="&lt;?php echo $loggedInUser-&gt;user_id ?&gt;" /&gt; Story Title: &lt;input type="text" name="story_name" /&gt;&lt;br&gt; Story: &lt;textarea rows="10" cols="30" name="story" /&gt;&lt;/textarea&gt;&lt;br&gt; &lt;input type="submit" /&gt; &lt;/form&gt; </code></pre> <p>Here's the PHP side:</p> <pre><code>include("dbconnect.php"); mysql_select_db("scratch", $con); $author = mysql_real_escape_string($_POST['author']); $author_id = mysql_real_escape_string($_POST['userid']); $story_name = mysql_real_escape_string($_POST['story_name']); $story = mysql_real_escape_string($_POST['story']); $sql= " INSERT INTO stories (author, author_id, story_name, story) VALUES ('$author', '$author_id','$story_name', '$story') "; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Story Submitted! Redirecting to Homepage..."; //User is shown this for about 3 seconds header('Refresh: 3; URL=index.php'); mysql_close($con) </code></pre> <p>I want to get rid of the </p> <pre><code>&lt;input type="hidden" name="author" value="&lt;?php echo $loggedInUser-&gt;display_username; ? &gt;"/&gt; </code></pre> <p>Since people could easily edit that and post as any user, but I'm unsure of a good way. Same goes for userid.</p> <p>Help is appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload