DEVILofDARKNESS Posted February 14, 2009 Share Posted February 14, 2009 I've done away all the php code because the problem is in the form, the script gives me except the form also this: Notice: Undefined index: PName in /www/zoombrowse.com/4/a/d/4ade/htdocs/gedichten/alledaagsedingen/toevoegenA.php on line 37 Notice: Undefined index: UName in /www/zoombrowse.com/4/a/d/4ade/htdocs/gedichten/alledaagsedingen/toevoegenA.php on line 38 Notice: Undefined index: PText in /www/zoombrowse.com/4/a/d/4ade/htdocs/gedichten/alledaagsedingen/toevoegenA.php on line 39 Notice: Undefined index: Auteur in /www/zoombrowse.com/4/a/d/4ade/htdocs/gedichten/alledaagsedingen/toevoegenA.php on line 40 Notice: Undefined index: bundel in /www/zoombrowse.com/4/a/d/4ade/htdocs/gedichten/alledaagsedingen/toevoegenA.php on line 41 Notice: Undefined index: jaartal in /www/zoombrowse.com/4/a/d/4ade/htdocs/gedichten/alledaagsedingen/toevoegenA.php on line 42 Notice: Undefined index: URL in /www/zoombrowse.com/4/a/d/4ade/htdocs/gedichten/alledaagsedingen/toevoegenA.php on line 46 Notice: Undefined index: submit in /www/zoombrowse.com/4/a/d/4ade/htdocs/gedichten/alledaagsedingen/toevoegenA.php on line 68 <html> <head><title>Gedichten</title> <link href='../../standard.css' type='text/css' rel='stylesheet' /> <link href="alledaags.css" type="text/css" rel="stylesheet" /> </head> <body> <?php print "<form action='' method='POST'> Jou Naam: <input type='text' maxlength='35' Name='UName'><br> Gedicht Naam: <input type='text' maxlength='75' Name='PName'><br> Auteur Naam: <input type='text' maxlength='35' Name='Auteur'><br> bundel: <input type='text' maxlength='35' Name='bundel'><br> Jaartal: <input type='text' maxlength='4' Name='jaartal'><br> Poem Text: <textarea COLS='60' ROWS='5' Name='PText'></textarea> <input type='hidden' name='URL' Value='{$url}'><br> <input type='submit' Value='Add!' name='submit'> <input type='reset'> </form>"; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/145172-solved-form-problem/ Share on other sites More sharing options...
Daniel0 Posted February 14, 2009 Share Posted February 14, 2009 That code does not generate those errors. Quote Link to comment https://forums.phpfreaks.com/topic/145172-solved-form-problem/#findComment-761969 Share on other sites More sharing options...
DEVILofDARKNESS Posted February 14, 2009 Author Share Posted February 14, 2009 What does? this is the whole piece of code: <html> <head><title>Gedichten</title> <link href='../../standard.css' type='text/css' rel='stylesheet' /> <link href="alledaags.css" type="text/css" rel="stylesheet" /> </head> <body> <table class='look' height='100%' width='100%' border='1'> <tbody> <tr> <td width='10%' height='100%'><iframe class='frames' src='../../functieknoppen/functieknoppenalledaags.htm' frameborder='0' width='100%' height='100%' scrolling='no'></iframe> </td> <td><center> <?php //data base settings are left away for security reasons :-) $query = sprintf("SELECT COUNT(DISTINCT URL) FROM gedichten WHERE category='alledaagsedingen'"); $result = mysql_query($query); list($url) = mysql_fetch_row($result); $url = $url + 1; print "<form action='' method='POST'> Jou Naam: <input type='text' maxlength='35' Name='UName'><br> Gedicht Naam: <input type='text' maxlength='75' Name='PName'><br> Auteur Naam: <input type='text' maxlength='35' Name='Auteur'><br> bundel: <input type='text' maxlength='35' Name='bundel'><br> Jaartal: <input type='text' maxlength='4' Name='jaartal'><br> Poem Text: <textarea COLS='60' ROWS='5' Name='PText'></textarea> <input type='hidden' name='URL' Value='{$url}'><br> <input type='submit' Value='Add!' name='submit'> <input type='reset'> </form>"; $query = sprintf("SELECT COUNT(DISTINCT id) FROM gedichten"); $result = mysql_query($query); list($id) = mysql_fetch_row($result); $id = $id + 1; $pname = $_POST['PName']; $uname = $_POST['UName']; $ptext = $_POST['PText']; $auteur = $_POST['Auteur']; $bundel = $_POST['bundel']; $jaartal = $_POST['jaartal']; $ip = $_SERVER['REMOTE_ADDR']; $added = date("d/m/y : H:i:s", time()) ; $str = "alledaagsedingen"; $url = "{$str}" . "{$_POST['URL']}"; $purl = "<html dir='ltr'> <head> <title>{$pname}</title> <link href='../../standard.css' type='text/css' rel='stylesheet' /> <link href='alledaags.css' type='text/css' rel='stylesheet' /> </head> <body> <table class='look' height='100%' width='100%' border='1'> <tbody> <tr> <td width='10%' height='100%'><iframe class='frames' src='../../functieknoppen/functieknoppengedicht.htm' frameborder='0' width='100%' height='100%' scrolling='no'></iframe> </td> <td><center> {$ptext} </center></td> </tr> </tbody> </table> </body> </html>"; if($_POST['submit']) { if(empty($_POST['PName'])) { print "<script type='text/javascript'>alert('Je hebt geen gedichten naam geschreven!');</script>"; } elseif(empty($_POST['UName'])) { print "<script type='text/javascript'>alert('Je hebt je naam niet geschreven!');</script>"; } elseif(empty($_POST['PText'])) { print "<script type='text/javascript'>alert('je hebt geen gedicht geschreven!');</script>"; } elseif(empty($_POST['Auteur'])) { print "<script type='text/javascript'>alert('Je hebt geen Auteur ingevuld, als je het niet weet, schrijf dan Onbekend of UnKnown!');</script>"; } else { $query = sprintf("INSERT INTO gedichten(id,PName,UName,PText,URL,category,Auteur,bundel,jaartal,ip,added) VALUES ('$id','$pname','$uname','$ptext','$url','alledaagsedingen','$auteur','$bundel','$jaartal','$ip','$added')"); $result = mysql_query($query); $new = fopen("$url.htm","x"); fwrite($new,"$purl"); print "<script type='text/javascript'>alert('Je gedicht is toegevoegd aan de 'alledaagsedingen' categorie);</script><a href='alledaagsedingen.php'>Zie alle gedichten</a>"; } } ?> </center></td> </tr> </tbody> </table> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/145172-solved-form-problem/#findComment-761977 Share on other sites More sharing options...
Daniel0 Posted February 14, 2009 Share Posted February 14, 2009 You would probably want to move code like $pname = $_POST['PName']; $uname = $_POST['UName']; $ptext = $_POST['PText']; $auteur = $_POST['Auteur']; $bundel = $_POST['bundel']; $jaartal = $_POST['jaartal']; inside the if($_POST['submit']) block. Those indexes won't exist in the $_POST array until your form has been submitted. Quote Link to comment https://forums.phpfreaks.com/topic/145172-solved-form-problem/#findComment-761980 Share on other sites More sharing options...
DEVILofDARKNESS Posted February 14, 2009 Author Share Posted February 14, 2009 All errors except one are gone. Thanks. But that one that still is there is: Notice: Undefined index: submit in /www/zoombrowse.com/4/a/d/4ade/htdocs/gedichten/alledaagsedingen/toevoegenA.php on line 37 but I can't move the submit to somewhere else!? Quote Link to comment https://forums.phpfreaks.com/topic/145172-solved-form-problem/#findComment-761990 Share on other sites More sharing options...
Daniel0 Posted February 14, 2009 Share Posted February 14, 2009 Change if($_POST['submit']) to if(isset($_POST['submit'])). You are accessing the submit index of the $_POST array. You can only do that if that index actually exists. Quote Link to comment https://forums.phpfreaks.com/topic/145172-solved-form-problem/#findComment-761998 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.