Non-anonymous questions

This commit is contained in:
posweg 2020-05-21 21:36:32 +00:00
parent 178dab9650
commit b92527f7b7
4 changed files with 11 additions and 5 deletions

View File

@ -1,5 +1,5 @@
- Functionality:
- Non-anonymous questions
- ~~Non-anonymous questions~~
- Answers
- Follows and followers (timeline)
- Actions redirections
@ -16,3 +16,7 @@
- Add various language support.
- Basic theme styling
- Relative time
- Bugs:
- Login redirection is broken
- Check that the user exists before keeping being logged like it

View File

@ -19,6 +19,8 @@ if(isset($_POST["post-submit"])){
$by = 0;
$question = htmlspecialchars($_POST["post-text"], ENT_QUOTES);
if(isset($_SESSION["uid"]) && !$_POST["anon"]) $by = $_SESSION["uid"];
// Insert user into DB
$db->exec("INSERT INTO questions(user,by,question,answered,date) VALUES ('$u','$by','$question',0,". strtotime('now') .");");
unset($_POST["post-text"]);

View File

@ -51,7 +51,7 @@ if(isset($_POST["reg"])){
$shadow = password_hash($_POST["password"], PASSWORD_DEFAULT);
// Insert user into DB
$db->exec("INSERT INTO users(username,shadow) VALUES ('$user','$shadow')");
$db->exec("INSERT INTO users(username,name,shadow) VALUES ('$user','$user','$shadow')");
unset($_POST["regname"],$_POST["password"],$_POST["invite"]);
$regErrorMsg = "Account created successfully";

View File

@ -34,11 +34,11 @@ if(isset($_SESSION["uid"])){
?>
<form name="input" action="/action/publish-question.php" method="post">
<p>Ask me anything</p>
<textarea id="post-text" name="post-text"></textarea>
<textarea placeholder="Ask me anything!" id="post-text" name="post-text"></textarea>
<br/>
<?php if(isset($errorMsg)) echo "<p>$errorMsg</p>\n"; ?>
<input type="hidden" name="uid" value="<?= $p_user["id"] ?>"/>
<p><input type="checkbox" <?php if(!isset($_SESSION["uid"])) echo("checked disabled"); ?> name="anon"/> Post anonymously</p>
<?php if(isset($errorMsg)) echo "<p>$errorMsg</p>\n"; ?>
<input type="submit" name="post-submit"/>
</form>