Page 1 of 1

Help with this code

Posted: Wed Sep 26, 2007 10:54 am
by Coldman
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

<?php

?>
                           <table align ="center" >
                            <form action="ManageTopics.php" method="POST">
                             <tr><td align="left" width=10>Tittle:</td>
                             <td align="left"><input name="title" type="text" size="25"  tabindex="1" /> </td></tr>
                             <tr><td align="left" width=10>Area:</td>
                             <td><input name="Area" type="text" size="25"  tabindex="2" /></td></tr>
                             <tr><td>Topic Description:</td></tr>
                             <tr><td COLSPAN="2"><textarea name="description" rows="15" cols="60" 

tabindex="3"></textarea></td></tr>
                              <tr><td><input type="submit" name="CreateTopic" value="Create Topic" /></td></tr>
                             </form> </table>
<?php
$submit= $_POST['CreateTopic'];
if($submit){
 $con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("cms", $con);
$TopicID=NULL;
$profId=10;
$title= $_POST['title'];
$Area= $_POST['Area'];
$Description= $_POST['description'];
$sql= "REPLACE INTO tbltopics
VALUES('$TopicID', '$title', '$Area', '$Description', '$profId')";
 if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "The topic Is Aded";

mysql_close($con);
}
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("cms", $con);
$query="SELECT Title FROM tbltopics";
$result=mysql_query($query);
$num=mysql_numrows($result);
echo "<b><center>Your Topics</center></b><br><br>";
$i=0;
while ($i < $num) {
$tittle=mysql_result($result,$i,"Title");
echo "<Table  align = center width='600'>";
$a=$i+1;
echo"<tr><td width='6'>$a</td><td width='100'>$tittle</td><td width='60'>View Description</td><td 

width='70'>Delete</td></tr></b>";
$i++;
echo"</table>";
}
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]2.[/b] Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.[/quote]

Posted: Wed Sep 26, 2007 11:02 am
by feyd
One may assume that if no explaination is given, few responses will be heard. This is especially true when someone simply posts a bunch of code.

Posted: Wed Sep 26, 2007 12:10 pm
by Coldman
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I found the solution  i put this code to see is the string that comes from form is empty:

Code: Select all

$profId=10;
$title= $_POST['title'];
$Area= $_POST['Area'];
$Description= $_POST['description'];


if ($title == "" ||  $Area == "" || $Description == "") {
   echo "The required fields are empty.";
} else {

anyway thanks


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]