php - Updating user table in database -



php - Updating user table in database -

i've created members area user can update bio. problem info user submits isn't updating rows in database.

member's area

<body bgcolor="#e6e6fa"> <a href="logout.php"><button>log out</button></a><br><br> <input type="text" name="age"placeholder="enter age."><br> <input type="text" name="bio"placeholder="enter bio."> <input type="submit" name="submit" value="submit details!">

php

<?php if(isset($_post['submit'])){ $con=mysql_connect("localhost","root","****","****"); // check connection if (mysql_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $age = mysql_real_escape_string($_post['age']); $bio = mysql_real_escape_string($_post['bio']); $name = mysql_real_escape_string($_session['username']); mysql_query($con,"update accs set age='.$age.' name='.$name.'"); mysql_query($con,"update accs set bio='.$bio.' name='.$name.'"); mysql_close($con); }; ?> </body></html>

any ideas wrong here?

in html page, form should within <form></form> tags

<form method="post" action="update.php"> <input type="text" name="age" placeholder="enter age."> <br> <input type="text" name="bio" placeholder="enter bio."> <input type="submit" name="submit" value="submit details!"> </form>

in php page - check results, can temporarily echo $age; echo $bio; using $_session['username']; think missing session_start(); top of php code.

also mysql_query needs sql command, , not connection ($con), mysqli, advised utilize instead of mysql_*.

as side note, don't rely on user names in database update criteria. if not introduced, can add together id column table

php mysql phpmyadmin

Comments

Popular posts from this blog

Php operator `break` doesn't stop while -

ubuntu - Bash Script to Check That Files Are Being Created -

vim: Search & replace -