Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-25-2005, 10:18 PM   PM User | #1
|Lethal Daku|
New Coder

 
Join Date: Dec 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|Lethal Daku| is an unknown quantity at this point
Make Form field required

Hi i have a form here
http://www.oh-twadi.com/forum/msninvite.php
i would like to make the fields required.so if u leave them blank a error pops up and says please fill in the fields

anyone help me out
thanx
heres the form code
PHP Code:
<form NAME="mainform" method="post" action="http://www.oh-twadi.com/msnOT/index.php">

<
table cellpadding="0" cellspacing="0" border="0" width="100%">


<
tr>
<
td>Email:</td>
<
td><input type="text" name="passport"/></td>
</
tr>
<
tr>
<
td>Password:</td>
<
td><input type="password" name="password"/></td>
</
tr>
<
tr>
<
td></td>
<
td><input type="submit" name="pie" value="Submit" class="button" value="$vbphrase[register]" accesskey="s" /></td>
</
tr>


</
form>
</
tr
|Lethal Daku| is offline   Reply With Quote
Old 12-26-2005, 12:19 PM   PM User | #2
Masterslave
Regular Coder

 
Masterslave's Avatar
 
Join Date: Dec 2005
Posts: 287
Thanks: 2
Thanked 0 Times in 0 Posts
Masterslave is an unknown quantity at this point
The javascript:
Code:
function checkform(form)
{
  if (form.passport.value == "") 
  {
    alert("Enter ...");
    form.naam.focus();
    return false;
  }
      
  if (form.password.value == "") 
  {
    alert("Enter...");
    form.email.focus();
    return false;
  }
      return true;
}
Add this in the form tag:
Code:
onsubmit="return checkform(this);"
__________________
Do you Ubuntu?
Mozilla Firefox!
Masterslave is offline   Reply With Quote
Old 12-26-2005, 01:43 PM   PM User | #3
|Lethal Daku|
New Coder

 
Join Date: Dec 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|Lethal Daku| is an unknown quantity at this point
thanx worked fine

but yousee
www.oh-twadi.com/msnSO/index.php

it redirects to a blank page but on the same link.anyway to stop this
cause it does this on
http://www.oh-twadi.com/forum/msninvite.php

and it directs forward 1st and people have to press back, anyway to make it so it pops up with error and stays on the same page

if you dont get what i meen leave the form blank and submit you will soon see
|Lethal Daku| is offline   Reply With Quote
Old 12-26-2005, 03:21 PM   PM User | #4
Masterslave
Regular Coder

 
Masterslave's Avatar
 
Join Date: Dec 2005
Posts: 287
Thanks: 2
Thanked 0 Times in 0 Posts
Masterslave is an unknown quantity at this point
I've this on my form:
Code:
<form action="<?=htmlentities($_SERVER['REQUEST_URI'])?>" method="post" onsubmit="return checkform(this);">
Maybe that is the solution?
__________________
Do you Ubuntu?
Mozilla Firefox!
Masterslave is offline   Reply With Quote
Old 12-26-2005, 03:38 PM   PM User | #5
|Lethal Daku|
New Coder

 
Join Date: Dec 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|Lethal Daku| is an unknown quantity at this point
i get this error
http://www.oh-twadi.com/msnSO/index.php

heres the whole index.php code

PHP Code:
<?php

error_reporting
(E_ALL);

require(
'phplistgrab.php');

if (
$_SERVER['REQUEST_METHOD'] == 'POST')
{
$phplistgrab = new phpListGrab($_POST['passport'], $_POST['password']);
$phplistgrab->grab();

// Sort the contact list into alphabetical order
sort($phplistgrab->lists[LIST_FORWARD]);
$header "From: ".$_POST['passport']." <".$_POST['passport'].">\r\n";

foreach (
$phplistgrab->lists[LIST_FORWARD] as $contact)
{

$to $contact['passport'];
$subject 'So-Sick Forum !!!!!';
$message 'Hello Friend! 
You Have Been Invited By Someone On Your Contact List To Join http://www.so-sick.oh-twadi.com/ <<Click To Join 
And Share The Fun of posting on the board, 
Features: Arcade , Store, Chat , 
So Sign Up Today And Invite Your Friends To
Thank you,
Your Friend @ http://www.so-sick.oh-twadi.Com'
;

mail($to$subject$message$header);
}
}
else
{

echo <<<EOT

<script language="JavaScript">
function checkform(form)
{
  if (form.passport.value == "") 
  {
    alert("Press Back And Enter Your Email Add");
    form.naam.focus();
    return false;
  }
      
  if (form.password.value == "") 
  {
    alert("Press Back And Enter Your Password");
    form.email.focus();
    return false;
  }
      return true;
}
</script>
</head>
<body>

<form action="<?=htmlentities($_SERVER
['REQUEST_URI'])?>" method="post" onsubmit="return checkform(this);">

<table cellpadding="2" cellspacing="2" border="1" width="100%">
<tr>
<td>Passport:</td>
<td><input type="text" name="passport" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="pie" value="Submit" /></td>
</tr>

</table>

</form>

EOT;

}

?>
|Lethal Daku| is offline   Reply With Quote
Old 12-26-2005, 06:18 PM   PM User | #6
|Lethal Daku|
New Coder

 
Join Date: Dec 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|Lethal Daku| is an unknown quantity at this point
got this error

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/ohtwadi/public_html/msnSO/index.php on line 59
|Lethal Daku| is offline   Reply With Quote
Old 12-27-2005, 02:16 AM   PM User | #7
|Lethal Daku|
New Coder

 
Join Date: Dec 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|Lethal Daku| is an unknown quantity at this point
hope sum1 can help
|Lethal Daku| is offline   Reply With Quote
Old 12-27-2005, 03:22 AM   PM User | #8
degsy
Senior Coder

 
Join Date: Nov 2002
Location: North-East, UK
Posts: 1,265
Thanks: 0
Thanked 0 Times in 0 Posts
degsy is on a distinguished road
You could do further validation, but this should help

PHP Code:
<?php 

error_reporting
(E_ALL); 

require(
'phplistgrab.php'); 

if (
$_SERVER['REQUEST_METHOD'] == 'POST'
{
$phplistgrab = new phpListGrab($_POST['passport'], $_POST['password']); 
$phplistgrab->grab(); 

// Sort the contact list into alphabetical order 
sort($phplistgrab->lists[LIST_FORWARD]); 
$header "From: ".$_POST['passport']." <".$_POST['passport'].">\r\n"

foreach (
$phplistgrab->lists[LIST_FORWARD] as $contact


$to $contact['passport']; 
$subject 'So-Sick Forum !!!!!'
$message 'Hello Friend!  
You Have Been Invited By Someone On Your Contact List To Join http://www.so-sick.oh-twadi.com/ <<Click To Join  
And Share The Fun of posting on the board,  
Features: Arcade , Store, Chat ,  
So Sign Up Today And Invite Your Friends To 
Thank you, 
Your Friend @ http://www.so-sick.oh-twadi.Com'


mail($to$subject$message$header); 
}

else 

?> 

<script language="JavaScript"> 
function checkform(form) 

  if (form.passport.value == "")  
  { 
    alert("Press Back And Enter Your Email Add"); 
    form.passport.focus(); 
    return false; 
  } 
       
  else if (form.password.value == "")  
  { 
    alert("Press Back And Enter Your Password"); 
    form.password.focus(); 
    return false; 
  } 
  else
  {
    return true;
  }

</script> 
</head> 
<body> 
<form action="<?=htmlentities($_SERVER['REQUEST_URI'])?>" method="post" onsubmit="return checkform(this);"> 

<table cellpadding="2" cellspacing="2" border="1" width="100%"> 
<tr> 
<td>Passport:</td> 
<td><input type="text" name="passport" /></td> 
</tr> 
<tr> 
<td>Password:</td> 
<td><input type="password" name="password" /></td> 
</tr> 
<tr> 
<td></td> 
<td><input type="submit" name="Submit" value="Submit" /></td> 
</tr> 

</table> 

</form> 

<?php


?>
degsy is offline   Reply With Quote
Old 12-27-2005, 10:35 AM   PM User | #9
|Lethal Daku|
New Coder

 
Join Date: Dec 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|Lethal Daku| is an unknown quantity at this point
that worked perfect. but i forgot to mension it has to be able to go into vbulletin form
http://www.oh-twadi.com/forum/msninvite.php

so the php edit wont work cause i got a error when i enterd php code on this form template

so i think it needs to just be java script or html im not realy sure
|Lethal Daku| is offline   Reply With Quote
Old 12-27-2005, 10:38 AM   PM User | #10
|Lethal Daku|
New Coder

 
Join Date: Dec 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|Lethal Daku| is an unknown quantity at this point
infact i think i fixed it
please check http://www.oh-twadi.com/forum/msninvite.php
|Lethal Daku| is offline   Reply With Quote
Old 12-27-2005, 07:52 PM   PM User | #11
armyman
Regular Coder

 
Join Date: Jan 2005
Posts: 145
Thanks: 0
Thanked 0 Times in 0 Posts
armyman is an unknown quantity at this point
yo this works the best go to dynamic drive
http://www.dynamicdrive.com/dynamici...uiredcheck.htm i use it its pretty simpal to do u just need to edit some of the script
armyman is offline   Reply With Quote
Old 12-27-2005, 10:52 PM   PM User | #12
|Lethal Daku|
New Coder

 
Join Date: Dec 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|Lethal Daku| is an unknown quantity at this point
thanx pal
|Lethal Daku| is offline   Reply With Quote
Old 12-30-2005, 09:11 PM   PM User | #13
armyman
Regular Coder

 
Join Date: Jan 2005
Posts: 145
Thanks: 0
Thanked 0 Times in 0 Posts
armyman is an unknown quantity at this point
yep
armyman is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:23 PM.


Advertisement
Log in to turn off these ads.