dongshuming7131 2017-06-09 10:49
浏览 27
已采纳

允许登录用户编辑其信息 - PHP / MySQL

I apologise if this question has been asked, I have looked and can't find an answer that fits but if I'm wrong please tell me!

I've created a login form and when the user logs in they can see their Name, E-mail, Phone and Availability. At the moment this is just echoing / printing the information from the MySQL database. What I was wondering is how I make this editable so that the logged in user can update their own information?

Thanks an absolute bunch to everyone by the way, I'm new to this site and everyone has been extremely helpful. I'm not a developer by trade and very much learning as I go on this project so it is appreciated! :)

<?php
session_start();
$sessData = !empty($_SESSION['sessData'])?$_SESSION['sessData']:'';
if(!empty($sessData['status']['msg'])){
$statusMsg = $sessData['status']['msg'];
$statusMsgType = $sessData['status']['type'];
unset($_SESSION['sessData']['status']);
}
?>
<div class="container">
<?php
    if(!empty($sessData['userLoggedIn']) && !empty($sessData['userID'])){
        include 'user.php';
        $user = new User();
        $conditions['where'] = array(
            'id' => $sessData['userID'],
        );
        $conditions['return_type'] = 'single';
        $userData = $user->getRows($conditions);
?>
<h2>Welcome <?php echo $userData['first_name']; ?>!</h2>
<a href="userAccount.php?logoutSubmit=1" class="logout">Logout</a>
<div class="regisFrm">
    <p><b>Name: </b><?php echo $userData['first_name'].' '.$userData['last_name']; ?></p>
    <p><b>Email: </b><?php echo $userData['email']; ?></p>
    <p><b>Phone: </b><?php echo $userData['phone']; ?></p>
<p><b>Available: </b><?php echo $userData['available']; ?></p>

<li><a href=profile.php>Update Profile<a></li><br>

<form action="change.php" method="post">
Are you available this weekend?<br>
<input type="radio" name="available" value="yes"> Yes<br>
<input type="radio" name="available" value="no"> No<br>
<input type="submit" value="Submit">
</form> 

</div>
<?php }else{ ?>
<h2>Login to Your Account</h2>
<?php echo !empty($statusMsg)?'<p class="'.$statusMsgType.'">'.$statusMsg.'</p>':''; ?>
<div class="regisFrm">
    <form action="userAccount.php" method="post">
        <input type="email" name="email" placeholder="EMAIL" required="">
        <input type="password" name="password" placeholder="PASSWORD" required="">
        <div class="send-button">
            <input type="submit" name="loginSubmit" value="LOGIN">
        </div>
    </form>
    <p>Don't have an account? <a href="registration.php">Register</a></p>
</div>
<?php } ?>
</div>
  • 写回答

1条回答 默认 最新

  • duanna3634 2017-06-09 10:55
    关注

    I am a newbie to php programming as well, so I very well could be wrong. I apologize in advance if this doesn't work. From what I understand of your question, why can't you make a form? I was in a similar situation before, and I just made a form asking for their details they wish to change and a password field. Transfer the data from the form to a .php file (using action='filename.php'), where you can make queries to update your mysql database.

    Hope it helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥15 帮我写一个c++工程