Hello! Trying to learn the language of PHP. I slowed down adding records to MySQL via html form. Html form:
<?php include_once "header.php"?> <?php include_once "menu.php"?> <?php include_once "leftblock.php"?> <div class="content" <form aсtion="/connect.php" method="post"> <label>Логин: </label> <input type="text" name="Pоle1" placeholder="Логин"><br> <label>Пароль:</label> <input type="password" name="Pоle2" placeholder="Пароль"><br> <label>Повторите пароль:</label> <input type="password" name="Pоle3" placeholder="Повторите пароль"><br> <label>Введите телефон:</label> <input type="tel" name="Pole4" placeholder=введите ваш телефон> <input type="submit" name="submit" value="Регистрация"> </form> </div> <?php include_once "footer.php"?> php form:
<?php $host = "localhost"; $user = "host1435288"; $password = "225a32a8"; $db = "host1435288_wwwnvr"; $connect = mysql_connect($host, $user, $password) or die ('error'); $select_db = mysql_select_db($db) or die ('error');?> <?php $i=$_POST['Pоle1']; $f=$_POST['Pоle2']; $n=$_POST['Pоle3']; $o=$_POST['Pоle4']; $link = mysql_pconnect("localhost","root","") or die ("Невозможно подключение к MySQL"); mysql_select_db("dog") or die ("Невозможно открыть таблицу с данными"); $query = ("INSERT INTO prepod (Pole1,Pole2,Pole3,Pole2) VALUES ('".$i."', '".$f."', '".$n."', '".$o."')"); mysql_query ( $query ); if ($query == 'true') echo "Добавлено в базу данных."; mysql_close ($link); ?> I can not understand what the error is.

mysql_*. For the general purposes of studying the principles incl. Web programming is not important final technology, PDO will be there or something else. better to question - teranmysql_querydemands two parameters. the first is the query string, the second is the connection. So the code should be$result = mysql_query($query, $link). After that, you in$resultwill havetrue/falsedepending on the execution. to compare$querywith the string"true"generally meaningless, because in$queryyou have the query text, and the string"true"is not at all in business. Soif($result){ ... }- teran