Jump to content

[SOLVED] My Form Doesn't Work...


tarun

Recommended Posts

Ive Had Previous Help With This But Now Theres ANOTHER Problem:

 

The Form Wont Submit - Why?

Please Help Me Thnx

 

Heres My Source Code

<?php
$addform = "<form name='addvideo' action='$PHP_SELF' method='post'>

Video URL:<BR><input type='text' name='url' size='40'>

<br>Video Description:<br><textarea rows='10' cols='30' name='desc'></textarea><br></form>

<input type='submit' value='Submit'>";

echo "$addform";

if (isset($_POST['Submit'])) {


$url = $_POST['url'];
$desc = $_POST['desc'];

if(empty($url)){
echo "Please Specify The URL Of The Video<br>";
}

elseif(empty($desc)){
echo "Please Specify A Description Of The Video<br>";
}

else{
$newcontent = "<videos>
<video url='$url' desc='$desc' />
</videos>";
$previouscontent = file_get_contents("videoplaylist.xml");
$openfile = fopen("videoplaylist.xml", "w");
$totalfile = $previouscontent.$newcontent;
fwrite($openfile, $totalfile);
fclose($openfile);

echo "File Added To Playlist<br><br>Add A New File?<br>$addform";
}


}
?>

Link to comment
Share on other sites

<?php
$PHP_SELF = $_SERVER['PHP_SELF'];
$addform = "<form name='addvideo' action='$PHP_SELF' method='post'>

Video URL:<BR><input type='text' name='url' size='40'>

<br>Video Description:<br><textarea rows='10' cols='30' name='desc'></textarea><br></form>

<input type='submit' value='Submit'>";

echo "$addform";

if (isset($_POST['Submit'])) {


$url = $_POST['url'];
$desc = $_POST['desc'];

if(empty($url)){
echo "Please Specify The URL Of The Video<br>";
}

elseif(empty($desc)){
echo "Please Specify A Description Of The Video<br>";
}

else{
$newcontent = "<videos>
<video url='$url' desc='$desc' />
</videos>";
$previouscontent = file_get_contents("videoplaylist.xml");
$openfile = fopen("videoplaylist.xml", "w");
$totalfile = $previouscontent.$newcontent;
fwrite($openfile, $totalfile);
fclose($openfile);

echo "File Added To Playlist<br><br>Add A New File?<br>$addform";
}


}
?>

Link to comment
Share on other sites

$PHP_SELF shouldn't work without defining it first.

<?php
$PHP_SELF = $_SERVER['PHP_SELF'];
$addform = "<form name='addvideo' action='$PHP_SELF' method='post'>

 

That was what I changed above.

 

<?php
$PHP_SELF = $_SERVER['PHP_SELF'];
$addform = "<form name='addvideo' action='$PHP_SELF' method='post'>

Video URL:<BR><input type='text' name='url' size='40'>

<br>Video Description:<br><textarea rows='10' cols='30' name='desc'></textarea><br></form>

<input type='submit' value='Submit' name="Submit"></form>";

echo "$addform";

if (isset($_POST['Submit'])) {


$url = $_POST['url'];
$desc = $_POST['desc'];

if(empty($url)){
echo "Please Specify The URL Of The Video<br>";
}

elseif(empty($desc)){
echo "Please Specify A Description Of The Video<br>";
}

else{
$newcontent = "<videos>
<video url='$url' desc='$desc' />
</videos>";
$previouscontent = file_get_contents("videoplaylist.xml");
$openfile = fopen("videoplaylist.xml", "w");
$totalfile = $previouscontent.$newcontent;
fwrite($openfile, $totalfile);
fclose($openfile);

echo "File Added To Playlist<br><br>Add A New File?<br>$addform";
}


}
?>

 

I changed the : <input type='submit' value='Submit' name="Submit"></form>"; this time around, see if that works.

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.