Jump to content

[SOLVED] need help in my form feature


pixeltrace

Recommended Posts

guys, i need help

please check

http://www.jobhirings.com/admean/email/blastsend2.php

 

on the file area, that one is not working and i dont know what wrong with my scripts

normally, what should happen there, if i select by specialization

the specialization list menu will appear below

and when i select individual email

the email field will appear below too.

 

below is the codes for this page

<?php
session_start();
ob_start();
include_once("FileUpload.php");
include_once("Functions.php");
//$dir = "D:/xampp/htdocs/test/data/";
$dir = "/home/museikne/www/misc/";
$active = false;
$error = "";
$text = "List:<br>";

$subject = stripslashes($_POST['SUBJECT']);
$header = isset($_POST['FROM']) ? stripslashes($_POST['FROM']) : "JobHiRings<postmaster@jobhirings.com>";
$url = isset($_POST['URL']) ? stripslashes($_POST['URL']) : "";
// Clear All
if(isset($_POST['CANCEL'])){
unset($_SESSION['LIST']);
unset($_SESSION['URL']);
}
// Clear URL Content
if(isset($_POST['CLEARURL']))unset($_SESSION['URL']);
if(isset($_POST['AMEND'])){
$_SESSION['URL'] = stripslashes($_POST['URLPREVIEW']);
}
// Get URL Content
if(isset($_POST['GETURL'])){
if(trim($_POST['URL']) == ""){
	$error = "Please fill in the url";
}else{
	$file = fopen($_POST['URL'], "r") or exit("Invalid URL!");
	//Output a line of the file until the end is reached
	while(!feof($file))
	  {
		$body .= fgets($file);
		//mail($email,"To $email", "Hi there!", "From: ncy@museik.net");
	  }
	fclose($file);
	//$body = str_replace("%name%", "chuyang", $body);
	$_SESSION['URL'] = $body;
}
}

// Import name list
if(isset($_POST['IMPORT'])){
$validFile = array("txt"); // valid file formats
$file = $_FILES['FILE'];
if($file['name'] != ''){
	unset($_SESSION['LIST']);
	$fu = new FileUpload($file, $dir);
	$fu->CheckFileFormat($validFile);
	$fu->UploadFile();
	$file = fopen($dir."list.txt", "r") or exit("Unable to open file!");
	//Output a line of the file until the end is reached
	while(!feof($file))
	{
		$email = fgets($file);
		$email = explode(",",$email);
		$_SESSION['LIST'][] = $email;
		//mail($email,"To $email", "Hi there!", "From: ncy@museik.net");
	}
	fclose($file);
}else{
	unset($_SESSION['LIST']);
	$error = "Please locate the file";
}
//header("Location:$PHP_SELF");
}
if(isset($_SESSION['LIST'])){
$i = 1;
foreach($_SESSION['LIST'] as $key=>$val){
	$name = $val[0];
	$email = $val[1];
	$text.= "$i ."."$name - $email<br>";
	$i++;
}
print $text;
}

if(isset($_POST['SEND'])){
if(trim($_POST['SUBJECT'] == ""))$error = "Please fill in a subject title";
if($error == ""){
	require_once("includes/Mail.php");
	$mail = new Mail();
	$mail->SetHeader($header);
	if(isset($_SESSION['LIST'])){
		$original_msg = $_SESSION['URL'];
		foreach($_SESSION['LIST'] as $key=>$val){
			$new_msg = str_replace("%name%", $val[0], $original_msg);
			$mail->SendHTML($val[1],$subject,$new_msg);
		}
		session_destroy();
		header("Location:$PHP_SELF");
	}
}
}
if($active){
$file = fopen("html.txt", "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
while(!feof($file))
  {
	$email .= fgets($file);

	//mail($email,"To $email", "Hi there!", "From: ncy@museik.net");
  }
fclose($file);
$email = str_replace("\"", "\\\"", $email);
print $email;
print "END";
}
//$bodytag = str_replace("'", "\'", $body);
echo $error;
?>
<form action="" method="post" enctype="multipart/form-data" name="form1">
  <table  border="0" cellspacing="0" cellpadding="3">
    <tr>
      <td nowrap>Subject:</td>
      <td><input name="SUBJECT" type="text" id="SUBJECT" value="<?php print $subject;?>"></td>
    </tr>
    <tr>
      <td>From:</td>
      <td><input name="FROM" type="text" id="FROM" value="<?php print $header;?>"></td>
    </tr>
    <tr>
      <td>File:</td>
      <td><span class="text7">
        <select name="to" class="textfield1">
          <option selected="selected" value="all">Entire list</option>
          <option value="notall">Specialization</option>
          <option value="peremail">Individual Email</option>
        </select>
        <input name="select" type="submit" id="select" value="select" />
      </span></td>
    </tr>
    <tr>
      <td> </td>
      <td><?php if(isset($_SESSION['to']) == "notall"){?>
  <select name="specialization">
      <option value="" selected="selected">-- select specialization here --</option>
      <?
		$uSql = "SELECT specialization FROM specialization";
		$uResult = mysql_query($uSql, $connection);
		if(!$uResult){
		echo 'no data found';
		}else{
		while($uRow = mysql_fetch_array($uResult)){
			?>
       <option value="<?= $uRow[specialization]?>"><?= $uRow[specialization]?></option>
       <?	}    } ?></select>
  <?php }?>
  
  <?php if(isset($_SESSION['to']) == "peremail"){?>
  <input name="peremail" type="text" class="textfield" maxlength="100" size="40" />
  <?php }?>
  </td>
    </tr>
    <tr>
      <td>URL:</td>
      <td><input name="URL" type="text" id="URL" value="<?php print $url;?>"></td>
    </tr>
    <tr>
      <td> </td>
      <td>
  <?php if(isset($_SESSION['URL'])){?>
  <textarea name="URLPREVIEW" cols="80" rows="10" id="URLPREVIEW"><?php print $_SESSION['URL']?></textarea>
  <br>
  <input name="CLEARURL" type="submit" id="CLEARURL" value="Clear">
  <input name="AMEND" type="submit" id="AMEND" value="Amend">
  <?php }?>
  <input name="GETURL" type="submit" id="GETURL" value="Get URL">      </td>
    </tr>
    <tr>
      <td> </td>
      <td><input name="SEND" type="submit" id="SEND" value="Send"> 
      <input name="CANCEL" type="submit" id="CANCEL" value="Cancel"></td>
    </tr>
  </table>
</form>
<?php ob_end_flush();?>

 

 

hope you could help me with this.

 

thanks!

Link to comment
Share on other sites

Hi!

 

Where u want to display Specialization and email value?

 

Is this should happen in PHP side( i mean after submission of the form) or JavaScript(HTML) side...

 

One more thing..why do u require that select button after menu display?

 

Explain little bit more.

 

Regards,

joshi.

Link to comment
Share on other sites

i want the specialization list menu or email field to appear just right below the file drop down menu

example, if i select individual email and i click select
the page will refresh and the email field will appear just below the select menu
notice in my code
[code]<td><?php if(isset($_SESSION['to']) == "notall"){?>
  <select name="specialization">
      <option value="" selected="selected">-- select specialization here --</option>
      <?
		$uSql = "SELECT specialization FROM specialization";
		$uResult = mysql_query($uSql, $connection);
		if(!$uResult){
		echo 'no data found';
		}else{
		while($uRow = mysql_fetch_array($uResult)){
			?>
       <option value="<?= $uRow[specialization]?>"><?= $uRow[specialization]?></option>
       <?	}    } ?></select>
  <?php }?>
  
  <?php if(isset($_SESSION['to']) == "peremail"){?>
  <input name="peremail" type="text" class="textfield" maxlength="100" size="40" />
  <?php }?>
  </td>

 

this is the condition that i want to happen but its not working

 

hope you could help me with this.

thanks![/code]

Link to comment
Share on other sites

 

For this you can use JavaScript and CSS together..without refreshing the page it will display the input fields according to the value selected in menu box.

 

 

#include this in JavaScript part of the form header.

 

<script language="JavaScript">

function event_action(spl_value)

{

if(spl_value=="Specialization")

{

test.visibility='show';

test2.visibility='hide';

}

else if(spl_value=="Individual Email")

{

test2.visibility='show';

test.visibility='hide';

}

}

# This is form part.

 

<td><?php if(isset($_SESSION['to']) == "notall"){

 

$uSql = "SELECT specialization FROM specialization";

$uResult = mysql_query($uSql, $connection);

 

if(mysql_num_rows($uResult)<=0)

{

echo 'no data found';

}

else

{

?>

  <select name="specialization" onClick="event_action(this.value);">

      <option value="" selected="selected">-- select specialization here --</option>

      <?php

      while($uRow = mysql_fetch_array($uResult)){

  ?>

      <option value="<?= $uRow[specialization];?>"><?= $uRow[specialization];?></option>

      </select>

<?php

}

?>

 

<div id="test" style="visibility:hide;" >

Email :  <input type="text" name="email" value="">

</div>

 

<div id="test2" style="visibility:hide;">

Specialization in : <input type="text" name="spl" value="">

</div>

 

 

Pls check CSS part carefully..i am not an expert in CSS .show there would eb mistakes in CSS part..But the total idea is correct!\

 

Hope it will help you.

 

Regards,

Joshi.

Link to comment
Share on other sites

its not working.

 

this is the current code of my entire page

<?php
session_start();
ob_start();
include_once("FileUpload.php");
include_once("Functions.php");
//$dir = "D:/xampp/htdocs/test/data/";
$dir = "/home/museikne/www/misc/";
$active = false;
$error = "";
$text = "List:<br>";

$subject = stripslashes($_POST['SUBJECT']);
$header = isset($_POST['FROM']) ? stripslashes($_POST['FROM']) : "JobHiRings<postmaster@jobhirings.com>";
$url = isset($_POST['URL']) ? stripslashes($_POST['URL']) : "";
// Clear All
if(isset($_POST['CANCEL'])){
unset($_SESSION['LIST']);
unset($_SESSION['URL']);
}
// Clear URL Content
if(isset($_POST['CLEARURL']))unset($_SESSION['URL']);
if(isset($_POST['AMEND'])){
$_SESSION['URL'] = stripslashes($_POST['URLPREVIEW']);
}
// Get URL Content
if(isset($_POST['GETURL'])){
if(trim($_POST['URL']) == ""){
	$error = "Please fill in the url";
}else{
	$file = fopen($_POST['URL'], "r") or exit("Invalid URL!");
	//Output a line of the file until the end is reached
	while(!feof($file))
	  {
		$body .= fgets($file);
		//mail($email,"To $email", "Hi there!", "From: ncy@museik.net");
	  }
	fclose($file);
	//$body = str_replace("%name%", "chuyang", $body);
	$_SESSION['URL'] = $body;
}
}

// Import name list
if(isset($_POST['IMPORT'])){
$validFile = array("txt"); // valid file formats
$file = $_FILES['FILE'];
if($file['name'] != ''){
	unset($_SESSION['LIST']);
	$fu = new FileUpload($file, $dir);
	$fu->CheckFileFormat($validFile);
	$fu->UploadFile();
	$file = fopen($dir."list.txt", "r") or exit("Unable to open file!");
	//Output a line of the file until the end is reached
	while(!feof($file))
	{
		$email = fgets($file);
		$email = explode(",",$email);
		$_SESSION['LIST'][] = $email;
		//mail($email,"To $email", "Hi there!", "From: ncy@museik.net");
	}
	fclose($file);
}else{
	unset($_SESSION['LIST']);
	$error = "Please locate the file";
}
//header("Location:$PHP_SELF");
}
if(isset($_SESSION['LIST'])){
$i = 1;
foreach($_SESSION['LIST'] as $key=>$val){
	$name = $val[0];
	$email = $val[1];
	$text.= "$i ."."$name - $email<br>";
	$i++;
}
print $text;
}

if(isset($_POST['SEND'])){
if(trim($_POST['SUBJECT'] == ""))$error = "Please fill in a subject title";
if($error == ""){
	require_once("includes/Mail.php");
	$mail = new Mail();
	$mail->SetHeader($header);
	if(isset($_SESSION['LIST'])){
		$original_msg = $_SESSION['URL'];
		foreach($_SESSION['LIST'] as $key=>$val){
			$new_msg = str_replace("%name%", $val[0], $original_msg);
			$mail->SendHTML($val[1],$subject,$new_msg);
		}
		session_destroy();
		header("Location:$PHP_SELF");
	}
}
}
if($active){
$file = fopen("html.txt", "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
while(!feof($file))
  {
	$email .= fgets($file);

	//mail($email,"To $email", "Hi there!", "From: ncy@museik.net");
  }
fclose($file);
$email = str_replace("\"", "\\\"", $email);
print $email;
print "END";
}
//$bodytag = str_replace("'", "\'", $body);
echo $error;
?>
<form action="" method="post" enctype="multipart/form-data" name="form1">
  <table  border="0" cellspacing="0" cellpadding="3">
    <tr>
      <td nowrap>Subject:</td>
      <td><input name="SUBJECT" type="text" id="SUBJECT" value="<?php print $subject;?>"></td>
    </tr>
    <tr>
      <td>From:</td>
      <td><input name="FROM" type="text" id="FROM" value="<?php print $header;?>"></td>
    </tr>
    <tr>
      <td>File:</td>
      <td><span class="text7">
        <select name="to" class="textfield1">
          <option selected="selected" value="all">Entire list</option>
          <option value="notall">Specialization</option>
          <option value="peremail">Individual Email</option>
        </select>
        <input name="select" type="submit" id="select" value="select" />
      </span></td>
    </tr>
    <tr>
      <td> </td>
      <td><?php if(isset($_SESSION['to']) == "notall"){?>
  <select name="specialization">
      <option value="" selected="selected">-- select specialization here --</option>
      <?
		$uSql = "SELECT specialization FROM specialization";
		$uResult = mysql_query($uSql, $connection);
		if(!$uResult){
		echo 'no data found';
		}else{
		while($uRow = mysql_fetch_array($uResult)){
			?>
       <option value="<?= $uRow[specialization]?>"><?= $uRow[specialization]?></option>
       <?	}    } ?></select>
  <?php }?>
  
  <?php if(isset($_SESSION['to']) == "peremail"){?>
  <input name="peremail" type="text" class="textfield" maxlength="100" size="40" />
  <?php }?>
  </td>
    </tr>
    <tr>
      <td>URL:</td>
      <td><input name="URL" type="text" id="URL" value="<?php print $url;?>"></td>
    </tr>
    <tr>
      <td> </td>
      <td>
  <?php if(isset($_SESSION['URL'])){?>
  <textarea name="URLPREVIEW" cols="80" rows="10" id="URLPREVIEW"><?php print $_SESSION['URL']?></textarea>
  <br>
  <input name="CLEARURL" type="submit" id="CLEARURL" value="Clear">
  <input name="AMEND" type="submit" id="AMEND" value="Amend">
  <?php }?>
  <input name="GETURL" type="submit" id="GETURL" value="Get URL">      </td>
    </tr>
    <tr>
      <td> </td>
      <td><input name="SEND" type="submit" id="SEND" value="Send"> 
      <input name="CANCEL" type="submit" id="CANCEL" value="Cancel"></td>
    </tr>
  </table>
</form>
<?php ob_end_flush();?>

 

 

 

 

Link to comment
Share on other sites

 

I think this will work in all broswers.

 

 

Please try this again..

 

 

<?php

session_start();

ob_start();

include_once("FileUpload.php");

include_once("Functions.php");

$dir = "D:/xampp/htdocs/test/data/";

$dir = "/home/museikne/www/misc/";

$active = false;

$error = "";

$text = "List:<br>";

 

$subject = stripslashes($_POST['SUBJECT']);

$header = isset($_POST['FROM']) ? stripslashes($_POST['FROM']) : "JobHiRings<postmaster@jobhirings.com>";

$url = isset($_POST['URL']) ? stripslashes($_POST['URL']) : "";

// Clear All

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

unset($_SESSION['LIST']);

unset($_SESSION['URL']);

}

// Clear URL Content

if(isset($_POST['CLEARURL']))unset($_SESSION['URL']);

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

$_SESSION['URL'] = stripslashes($_POST['URLPREVIEW']);

}

// Get URL Content

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

if(trim($_POST['URL']) == ""){

$error = "Please fill in the url";

}else{

$file = fopen($_POST['URL'], "r") or exit("Invalid URL!");

//Output a line of the file until the end is reached

while(!feof($file))

  {

$body .= fgets($file);

//mail($email,"To $email", "Hi there!", "From: ncy@museik.net");

  }

fclose($file);

//$body = str_replace("%name%", "chuyang", $body);

$_SESSION['URL'] = $body;

}

}

 

// Import name list

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

$validFile = array("txt"); // valid file formats

$file = $_FILES['FILE'];

if($file['name'] != ''){

unset($_SESSION['LIST']);

$fu = new FileUpload($file, $dir);

$fu->CheckFileFormat($validFile);

$fu->UploadFile();

$file = fopen($dir."list.txt", "r") or exit("Unable to open file!");

//Output a line of the file until the end is reached

while(!feof($file))

{

$email = fgets($file);

$email = explode(",",$email);

$_SESSION['LIST'][] = $email;

//mail($email,"To $email", "Hi there!", "From: ncy@museik.net");

}

fclose($file);

}else{

unset($_SESSION['LIST']);

$error = "Please locate the file";

}

//header("Location:$PHP_SELF");

}

if(isset($_SESSION['LIST'])){

$i = 1;

foreach($_SESSION['LIST'] as $key=>$val){

$name = $val[0];

$email = $val[1];

$text.= "$i ."."$name - $email<br>";

$i++;

}

print $text;

}

 

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

if(trim($_POST['SUBJECT'] == ""))$error = "Please fill in a subject title";

if($error == ""){

require_once("includes/Mail.php");

$mail = new Mail();

$mail->SetHeader($header);

if(isset($_SESSION['LIST'])){

$original_msg = $_SESSION['URL'];

foreach($_SESSION['LIST'] as $key=>$val){

$new_msg = str_replace("%name%", $val[0], $original_msg);

$mail->SendHTML($val[1],$subject,$new_msg);

}

session_destroy();

header("Location:$PHP_SELF");

}

}

}

if($active){

$file = fopen("html.txt", "r") or exit("Unable to open file!");

//Output a line of the file until the end is reached

while(!feof($file))

  {

$email .= fgets($file);

 

//mail($email,"To $email", "Hi there!", "From: ncy@museik.net");

  }

fclose($file);

$email = str_replace("\"", "\\\"", $email);

print $email;

print "END";

}

//$bodytag = str_replace("'", "\'", $body);

echo $error;

?>

<html>

<head>

<script language="JavaScript">

function event_action(spl_value)

{

  if(spl_value=="peremail")

  {

      test.style.visibility="visible";

      test2.style.visibility='hidden';

  }

  else if(spl_value=="notall")

  {

      test2.style.visibility="visible";

      test.style.visibility='hidden';

  }

  else

  {

  test.style.visibility='hidden';

  test2.style.visibility='hidden';

  }

}

</script>

</head>

<body>

<form action="<?=$PHP_SELF;?>" method="post" enctype="multipart/form-data" name="form1">

  <table  border="0" cellspacing="0" cellpadding="3">

    <tr>

      <td nowrap>Subject:</td>

      <td><input name="SUBJECT" type="text" id="SUBJECT" value="<?php print $subject;?>"></td>

    </tr>

    <tr>

      <td>From:</td>

      <td><input name="FROM" type="text" id="FROM" value="<?php print $header;?>"></td>

    </tr>

    <tr>

      <td>File:</td>

      <td><span class="text7">

        <select name="to" class="textfield1" onChange="event_action(this.value);" >

          <option selected="selected" value="all">Entire list</option>

          <option value="notall">Specialization</option>

          <option value="peremail">Individual Email</option>

        </select>

        <!--<input name="select" type="submit" id="select" value="select" />//-->

      </span></td>

    </tr>

    <tr><td colspan="2">

    <div id="test" style="visibility:hidden;" >

Email :  <input type="text" name="email" value="">

</div>

 

<div id="test2" style="visibility:hidden;">

Specialization in : <input type="text" name="spl" value="">

</div></td>

    </tr>

    <tr>

      <td> </td>

      <td><?php if(isset($_SESSION['to']) == "notall"){?>

  <select name="specialization">

      <option value="" selected="selected">-- select specialization here --</option>

      <?

$uSql = "SELECT specialization FROM specialization";

$uResult = mysql_query($uSql, $connection);

if(!$uResult){

echo 'no data found';

}else{

while($uRow = mysql_fetch_array($uResult)){

?>

      <option value="<?= $uRow[specialization]?>"><?= $uRow[specialization]?></option>

      <? }    } ?></select>

  <?php }?>

 

  <?php if(isset($_SESSION['to']) == "peremail"){?>

  <input name="peremail" type="text" class="textfield" maxlength="100" size="40" />

  <?php }?>

  </td>

    </tr>

    <tr>

      <td>URL:</td>

      <td><input name="URL" type="text" id="URL" value="<?php print $url;?>"></td>

    </tr>

    <tr>

      <td> </td>

      <td>

  <?php if(isset($_SESSION['URL'])){?>

  <textarea name="URLPREVIEW" cols="80" rows="10" id="URLPREVIEW"><?php print $_SESSION['URL']?></textarea>

  <br>

  <input name="CLEARURL" type="submit" id="CLEARURL" value="Clear">

  <input name="AMEND" type="submit" id="AMEND" value="Amend">

  <?php }?>

  <input name="GETURL" type="submit" id="GETURL" value="Get URL">      </td>

    </tr>

    <tr>

      <td> </td>

      <td><input name="SEND" type="submit" id="SEND" value="Send">

      <input name="CANCEL" type="submit" id="CANCEL" value="Cancel"></td>

    </tr>

  </table>

</form>

</body>

</html>

<?php ob_end_flush();?>

 

 

 

Let me know the result of it.

 

Regards,

joshi.

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.