Jump to content

[SOLVED] form problem


DEVILofDARKNESS

Recommended Posts

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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.