Jump to content

[SOLVED] problem getting if statement to work


Rodis

Recommended Posts

Hey you guys need some help again.

 

I am trying to check if some post fields are filled in and if they are empty echo a line and else let them through into the fdatabase.

 

I have come up with the following code but it will not let me go handle the else statement even if they are filled. this is my code.

if (isset($_GET['action'])){

$pagina = $_GET['action'];
if ($pagina == 'toevoegen'){
	if (strlen($_POST['keywords']) || strlen($_POST['link']) || strlen($_POST['categorie']) || strlen($_POST['taal']) || strlen($_POST['naam']) < 1 ){
		echo GOBACKFIELDS;
		echo("<p>");
		echo HISTORYGOBACK1;
		echo("<p>");
		//tes
		$omschrijving = mysql_escape_string(strip_tags($_POST['omschrijving']));
		echo $omschrijving;
		echo strlen($_POST['keywords']);
		//end test
	}
	else{

		// gegevens om de datum van plaatsing vast te stellen.
		$post_day = date("d");
		$post_month = date("m"); 
		$post_year = date("Y");
		$post_date = mktime(0,0,0,$post_month,$post_day,$post_year);
		//Hier komt het script wat de gegevens in de database plaatst.
		//$post_date = $_POST['post_date'];
		$categorie = mysql_escape_string(strip_tags($_POST['categorie']));
		$subcategorie = mysql_escape_string(strip_tags($_POST['subcategorie']));
		$taal = mysql_escape_string(strip_tags($_POST['taal']));
		$naam = mysql_escape_string(strip_tags($_POST['naam']));
		$link = mysql_escape_string($_POST['link']);
		$omschrijving = mysql_escape_string($_POST['omschrijving']);
		$image = mysql_escape_string(strip_tags($_POST['image']));
		$tip = mysql_escape_string(strip_tags($_POST['tip']));
		$keywords = mysql_escape_string(strip_tags($_POST['keywords']));
		$dag = mysql_escape_string(strip_tags($_POST['dag']));
		$maand = mysql_escape_string(strip_tags($_POST['maand']));
		$jaar = mysql_escape_string(strip_tags($_POST['jaar']));
		$validation_date = mktime(0,0,0,$maand,$dag,$jaar);
		$email = mysql_escape_string(strip_tags($_POST['email']));
		$opmerking = mysql_escape_string($_POST['opmerking']);

		mysql_query("INSERT INTO sb_link_info (post_date, cat, subcat, taal, l_naam, link, omschrijving, image, tip, keywords, validation_date, email_adver, opmerkingen) VALUES ('$post_date','$categorie','$subcategorie','$taal','$naam','$link','$omschrijving','$image','$tip','$keywords','$validation_date','$email','$opmerking')") or die(mysql_error()); 
		echo 'Je bericht is opgeslagen!  <a href="../index.php">klik hier als je niet wordt doorgestuurt</a>';

	}	
}

}else{

echo "Er is geen actie aan de pagina meegegeven.";
}

probebly i am doing it all wrong can anybody help check fields and if so go on and throw it into my database?

 

Thanks in advance.

As you can see in my script i am using all $_POST. anyways here is the form code.

 

<form name="newlink" method="post" action="index.php?option=db_schrijven&action=toevoegen">
<table width="100%"  cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="3"><div align="center"><strong><? echo DATANEWLINK ?></strong></div></td>
  </tr>
  <tr>
    <td><? echo CATEGORY ?></td>
    <td><strong>:</strong></td>
    <td><select name="categorie" onChange="changecat(this.options[this.selectedIndex].id)">
      <option></option>
      <? categorie(); ?>
    </select></td>
  </tr>
  <tr>
    <td><? echo SUBCATEGORY ?></td>
    <td><strong>:</strong></td>
    <td><select name="subcategorie" onChange="MM_jumpMenu('parent',this,0)">
      <option></option>
      <? subcategorie(); ?>
    </select></td>
  </tr>
  <tr>
    <td><? echo LANGUAGE_SITE ?></td>
    <td><strong>:</strong></td>
    <td><select name="taal" onChange="MM_jumpMenu('parent',this,0)">
      <? taal() ?>
    </select></td>
  </tr>
  <tr>
    <td><? echo NAME_LINK ?></td>
    <td><strong>:</strong></td>
    <td><input type="text" name="naam" size="50"></td>
  </tr>
  <tr>
    <td><? echo LINK_URL ?></td>
    <td><strong>:</strong></td>
    <td><input type="text" name="link" size="100"></td>
  </tr>
  <tr>
    <td valign="top"><? echo DESCRIPTION ?></td>
    <td valign="top"><strong>:</strong></td>
    <td>
      <textarea name="omschrijving" cols="80" rows="15"></textarea>	</td>
  </tr>
  <tr>
    <td><? echo IMAGE ?></td>
    <td><strong>:</strong></td>
    <td><input type="text" name="image" size="50"></td>
  </tr>
  <tr>
    <td><? echo TIP ?></td>
    <td><strong>:</strong></td>
    <td><select name="tip" onChange="MM_jumpMenu('parent',this,0)">
      <option selected value="False">nee</option>
      <option value="True">Ja</option>
    </select></td>
  </tr>
  <tr>
    <td><? echo KEYWORDS ?></td>
    <td><strong>:</strong></td>
    <td><input type="text" name="keywords" size="105"></td>
  </tr>
  <tr>
    <td colspan="3"><div align="center"><strong><? echo EXPIREDATE ?></strong></div></td>
  </tr>
  <tr>
    <td><span class="style1"><? echo MAXDATE ?></span></td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td><? echo DAY ?></td>
    <td><strong>:</strong></td>
    <td><input type="text" name="dag" size="50"></td>
  </tr>
  <tr>
    <td><? echo MONTH ?></td>
    <td><strong>:</strong></td>
    <td><input type="text" name="maand" size="50"></td>
  </tr>
  <tr>
    <td><? echo YEAR ?></td>
    <td><strong>:</strong></td>
    <td><input type="text" name="jaar" size="50"></td>
  </tr>
  <tr>
    <td colspan="3"><div align="center"><strong><? echo DATA_ADVERTISER ?></strong></div></td>
    </tr>
  <tr>
    <td><? echo EMAIL ?></td>
    <td><strong>:</strong></td>
    <td><input type="text" name="email" size="50"></td>
  </tr>
  <tr>
    <td valign="top"><? echo NOTES ?></td>
    <td valign="top"><strong>:</strong></td>
    <td><textarea name="opmerking" cols="80" rows="5"></textarea></td>
  </tr>
  <tr>
    <td colspan="3"><div align="center">
      <input name="Submit" type="submit" value="<? echo BUTTON_SUBMIT ?>">
    </div></td>
    </tr>
</table>
</form>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.