Hello, originally i downloaded a CMS with this PHP code in it: <?php $faila= file("config.inc"); $config = explode ("|",$faila[0]); if($_POST['buton']) { $grad=htmlspecialchars($_POST['grad']); $ip=$_SERVER["REMOTE_ADDR"]; $query1="SELECT * from grad where name like '$grad' "; $result1=mysql_query($query1); if ($_POST['grad'] == NULL) { echo "<b>Blah-blah!</b><br><br><a href=\"\">Blah-Blah</a>"; } else { if (mysql_num_rows($result1)>0) { echo "Blah-blah <b>$grad</b> Blah-Blah!<br>Blah-blah.<br><br><a href=\"\">Blah-Blah</a>"; } else { $kolko_simvola = strlen($grad); if ($kolko_simvola > $config[1]) { echo "Blah-blah!<br>Blah-blah.<br><br><a href=\"\">ВЪРÐИ</a>"; } else { if ($code == $_POST['code2']) { $sql = "INSERT INTO `grad` VALUES('', '$grad', '1' );"; if(mysql_query($sql) != "") { $query = mysql_query("SELECT * FROM `grad` WHERE name='$grad' LIMIT 1;"); $row=mysql_fetch_array($query); $gradid=$row[id]; $grad=$row[name]; $sql2 = "INSERT INTO `gradip` VALUES('', '$gradid', '$ip' );"; $q=mysql_query($sql2); $grad = stripslashes($grad); echo "Blah-blah <b>$grad</b> Blah-blah!<br><br>"; echo "Blah-blah<b><a href=\"$path=$gradid\">$path=$gradid</a></b><br>"; echo "Blah-blah: <b>$ip</b>"; $HTTP_SESSION_VARS['code'] = 0; }else { echo "Blah-blah"; } } else { echo "Blah-blah<br><br><a href=\"\">Blah-blah</a>"; } } } } } ?> <?php PHP: Everything is OK with this. I have a normal TextField and another one for captcha code. I got a database with two tables "grad" and "gradip". In the "grad" table there are 3rows - id name jitel . I added a new row in the table "grad" with the name "skype". I added a new text field (grad2) in the site under the "name" text field (grad). I need to connect my grad2 text field with the "skype" row in the table, but i don't know how. I tried some different changes in the code, but nothing worked. I made the code looks like this: <?php $faila= file("config.inc"); $config = explode ("|",$faila[0]); if($_POST['buton']) { $grad=htmlspecialchars($_POST['grad']); $ip=$_SERVER["REMOTE_ADDR"]; $query1="SELECT * from grad where name like '$grad' "; $result1=mysql_query($query1); if ($_POST['grad'] == NULL) { echo "<b>Blah-Blah!</b><br><br><a href=\"\">Blah-Blah</a>"; } else { if (mysql_num_rows($result1)>0) { echo "Blah-Blah <b>$grad</b> Blah-Blah!<br>Blah-Blah.<br><br><a href=\"\">ВЪРÐИ</a>"; } else { $kolko_simvola = strlen($grad); if ($kolko_simvola > $config[1]) { echo "Blah-Blah $config[1] Blah-Blah!<br>Blah-Blah.<br><br><a href=\"\">Blah-Blah</a>"; } else { if ($code == $_POST['code2']) { $sql = "INSERT INTO `grad` VALUES('', '$grad', '1', '$grad2' );"; if(mysql_query($sql) != "") { $query = mysql_query("SELECT * FROM `grad` WHERE skype='$grad2' LIMIT 1; "); $query = mysql_query("SELECT * FROM `grad` WHERE name='$grad' LIMIT 1; "); $row=mysql_fetch_array($query); $gradid=$row[id]; $grad=$row[name]; $grad2=$row[skype]; $sql2 = "INSERT INTO `gradip` VALUES('', '$gradid', '$ip' );"; $q=mysql_query($sql2); $grad = stripslashes($grad); $grad2 = stripslashes($grad2); echo "Blah-Blah <b>$grad</b> Blah-Blah!<br><br>"; echo "Blah-Blah <b><a href=\"$path=$gradid\">$path=$gradid</a></b><br>"; echo "Blah-Blah: <b>$ip</b>"; $HTTP_SESSION_VARS['code'] = 0; }else { echo "Blah-Blah"; } } else { echo "Blah-Blah!<br><br><a href=\"\">Blah-Blah</a>"; } } } } } ?> <?php PHP: I think (hope) I'm almost ready, but when i enter the three text fields (name, skype, code) I got the name in the database, but I don't get the skype text field information. That's all...
You have checked in the database, that there is nothing in the Skype-fields? At least one problem is with this code: $query = mysql_query("SELECT * FROM `grad` WHERE skype='$grad2' LIMIT 1; "); $query = mysql_query("SELECT * FROM `grad` WHERE name='$grad' LIMIT 1; "); PHP: The second $query will overwrite the first one. So the first $query will never be executed. That might have something to do with it, but I can't be sure. Try echoing the first INSERT instead of running it with mysql_query, to see what is actually being sent to the database.