Created
November 12, 2013 12:53
-
-
Save nilsmunch/7430320 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if($_POST["Forfatter"] && $_POST["Title"] && $_POST["Content"]) { | |
mysql_connect('localhost','root',''); | |
mysql_select_db('phpopgave_PBG') or die(mysql_error()); | |
$newsarticle = array('title' => $_POST["Title"], 'author' => $_POST["Forfatter"],'content'=>$_POST["Content"]); | |
if($_POST["opret_nyhed"]) { | |
if (array_search('', $newsarticle) !== false) { | |
die("Fyld venglist alle felter ud."); | |
} | |
if(filter_var($newsarticle['author'], FILTER_SANITIZE_NUMBER_INT)) { | |
die("Ingen tal i forfatter navn!"); | |
} | |
$newsQ = 'INSERT INTO nyheder ('.impode(',',array_keys($newsarticle)).',date) VALUES ("'.impode('","',$newsarticle).'",NOW())'; | |
mysql_query($newsQ) or die(mysql_error()); | |
echo "Nyheden er tilføjet"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment