hielo 65 Veteran Poster

<input Fahrenheit = "Fahrenheit" ..> should be: <input [B]id[/B] = "Fahrenheit" ..> The same goes for the other input. Also, this is wrong:
answer2 = (9.0/5.0) * (temp2 + 32);

You need to add 32 AFTER the multiplication. Lastly, if you are executing convertC() simply returning the result is useless because you are not displaying anywhere. You should be assigning the result do the Fahrenheit input. The same goes for the other function.

<?xml version= "1.0: encoding = "utf-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



<!-- homework 9.19 -->

<html xmlns = "http://www.w3.org/1999/xhtml">

<head>
<title> Fahrenheit and Celsius Converter </title>

<script type = "text/javascript">

//make convertC function
function convertC()
{

  //get the number form field
var field1 = document.getElementById("Celsius");
var temp1 = parseFloat(field1.value);
var answer1 = 0;

answer1 = (5.0/9.0) * (temp1 - 32);
 document.getElementById("Fahrenheit").value=answer1.toFixed(1);
return answer1;
}

//make converF funtion
function convertF()
{
var field2 = document.getElementById("Fahrenheit");
var temp2 = parseFloat(field2.value);
var answer2 = 0;

answer2 = (9.0/5.0) * (temp2 + 32);
document.getElementById("Celsius").value=answer2.toFixed(1);
return answer2;
}
</script>

</head>

<body>

<h1> Fahrenheit and Celsius Converter </h1>

<table border = "1" width = "35%">

<thead>

<tr>

  <td>Fahrenheit</td>
  <td><input id = "Celsius" type = "text" size = "25" /></td>
  <td><input type = "button" value = "Convert to Celsius"
        onclick = "convertC()" </td>
</tr>
<tr>
  <td>Celsius</td>
  <td><input id = "Fahrenheit" type = "text" size = "25" /></td>
  <td><input type = "button" value = "Convert to Fahrenheit" 
        onclick = "convertF()"</td>
</tr>

</table>

</body>

</html>
hielo 65 Veteran Poster

What EXACTLY are you trying to do?

hielo 65 Veteran Poster

and it will save the info submitted so it can be viewed anytime?

No. None of what I posted will save the data permanently. It saves it only for the duration of the Session - meaning, while the browser remains opened AND while the user remains making request with your site for X number of minutes, where X depends on your server configuration.

To save the data permanently, you will need a database OR save it to a file. I suggest you read PHP tutorials before attempting this.

hielo 65 Veteran Poster

OK, then basically all you need is file1.php and emailIt.php. Just make sure that in file1.php you use <form action="emailIt.php" method="post">

hielo 65 Veteran Poster

why would we make the person fill out another form?...Im just really lost, why there are 3 pages for this code?

Your ORIGINAL problem description was:

I have a form on page 2 and I want the information submitted on the form to be sent to page 3. How do i do that?

So YOU made it sound like there are THREE pages involved.

hielo 65 Veteran Poster

So i tried it, I made 3 new files with the names you said to test it.
page1.php
sendresults.php
emailIt.php

OK, but did you change the action attribute on the <form> . If you left <form action="php/sendresults.php" id="email" method="post"> it will not work. Assuming you created all those new files in the same folder, then you should have: <form action="sendresults.php" id="email" method="post"> and <form method="post" action="emailIt.php">

hielo 65 Veteran Poster

page 1 and page 2 are .html not .php files. does that make a difference?

Yes. They must be PHP files.

this the form I am using

That is NOT a form. What you have are TWO forms. The submit button applies ONLY to the second form, so you will never see what is entered in the Message and Contact Info because that first form is never submitted. You just merge the forms into one.

<!-- consider this page1.php -->
<div id="apDiv1">
<form action="php/sendresults.php" id="email" method="post">
<textarea name="Message" cols="50" rows="10">Hi my name is………</textarea>
<br />
<br />
<textarea name="Contact info" cols="50">contact info</textarea>

<input type="submit" value="Submit" />
</form>

</div>

Then in sendresults.php

<?php
session_start();
//here you are saving the data sent from previous form onto $_SESSION
foreach($_POST as $fieldName=>$value){
  $_SESSION[$fieldName]=$value;
}

//now we give the user another form to fill. Basically this is acting as page2.php
//notice that we are submitting to emailIt.php (which is basically your page3.php)
?>
<form method="post" action="php/emailIt.php">
<div>Full Name: <input type="text" name="name" value=""/></div>
<div>Email: <input type="text" name="email" value=""/></div>
<input type="submit" name="Send" value="Submit"/>
</form>

Finally on the last page you can process all the data at once:

<?php
session_start();

//here I am printing the stuff that was submitted on the first form
foreach($_SESSION as $k=>$v){
  echo $k . '=' . $v.'<br>';
}

//now I am printing the stuff sent by the second form
foreach($_POST as $k=>$v){
  echo $k . '=' . $v.'<br>';
}

If you wanted, you could combine the data from the forms onto a …

hielo 65 Veteran Poster

You can save it onto a $_SESSION variable. Assuming that on page1.php you are submitting a POST request (as opposed to a get), then on page2.php:

<?php
session_start();

foreach($_POST as $fieldName=>$value){
  $_SESSION[$fieldName]=$value;
}
?>

Then on page3.php

<?php
session_start();
//for the sake of clarity, let's say that on form1.php you had:
//<input type="text" name="firstName" />
//then page2.php created $_SESSION["firstName"] in the foreach constructed I gave you
//So here you can simply retrieve that value (just make sure you always call 
//session_start() at the beginning of the file first)
echo $_SESSION['firstName'];
?>
hielo 65 Veteran Poster

change it to: $xmlBody .= '<?xml-stylesheet type="text/xsl" href="books06.xsl"?>';

hielo 65 Veteran Poster

The "locationName" has a higher priority than the alternateName, if the searchterm matches both.

ifnull(alternateName,locationName) as theName does not accommodate that requirement

hielo 65 Veteran Poster

Try doing a UNION query and insert a "priority" field depending on which one it is:

NOTE: on the example below, $term represents the value you are searching for

SELECT  locationID, locationName, 1 as priority FROM locations WHERE locationName LIKE '$term%'
      UNION ALL
      SELECT locationID, alternateName, 2 as priority FROM alternateNames WHERE  alternateName LIKE '$term%'
ORDER BY priority ASC"
hielo 65 Veteran Poster

you created TWO DIFFERENT objects. One is a Father object. The other is a Son object. The Son object:
a. Sets the value of car and ...
b. inherits from the Father

So try: $obj1->inherited(); to see the value of car. Maybe this will clear things up for you:

<?php
Class Father{

	var $car="Toyota";
	
	Function inherited(){
	print $this->car;
	}
}

Class Son Extends Father{

	Function __Construct(){
	$this->car='Benz';//I'm assuming here that car is still a property of father.
	}
}

$obj= new Father;
$obj1= new Son;

# I expect it to print Benz here, but it doesn't.
$obj->inherited();//father object
echo '<br>';
$obj1->inherited();//son object
#There is no output.
?>
hielo 65 Veteran Poster

http://aquantum-demo.appspot.com/file-upload
http://www.uploadify.com/demos/

PS: Don't forget to mark this thread as solved. Your original problem was solved long ago.

hielo 65 Veteran Poster

Glad to help.

Regards,
Hielo

PS: Don't forget to mark the thread as solved

hielo 65 Veteran Poster

I don't know where your have

<h1>Welcome<?php require ('name.php'); ?> to your private page!</h1>

but the problem is that on the file where you are including FROM, you already send output to the browser (since in your code <h1>Welcome... appears before the include).

Let's assume that the page you are working on is at http://yoursite.com/yourpage.php and that yourpage.php includes name.php.

Then you need to call session_start() at the very top of yourpage.php and NOT at name.php. All this confusion is because you did not provide enough details about your application. When working with sessions and includes, you need to be very clear as to which files are including other files.

hielo 65 Veteran Poster

again

<?php
session_start();
require ('name.php');
?>

needs to be at the BEGINNING of the FILE. You have it in the middle.

hielo 65 Veteran Poster

You need it at the beginning of ALL three files. Also, in Name.php you have: if (isset($_SESSION['email'])) BUT in LOGIN.php you are NOT initializing $_SESSION['email'] anywhere. All you have is:

$_SESSION["login"] = $login;
$_SESSION["username"] = $_POST["username"];

Maybe you meant: if (isset($_SESSION['login']))

hielo 65 Veteran Poster

use the bind_param() method to extract the values. See Example 1:
http://us.php.net/manual/en/mysqli.prepare.php

hielo 65 Veteran Poster

on EVERY page where you are using $_SESSION, you MUST call session_start() first. So, at the very top of your pages, BEGIN with:

<?php
session_start();
//rest of your code follows
...
?>
hielo 65 Veteran Poster

a comma separated list of email addresses is OK. It is even shown in example 4 on the manual:
http://php.net/manual/en/function.mail.php

cguan_77 commented: thanks +0
hielo 65 Veteran Poster

On line 15 of the code you posted, you forgot a semicolon at the end of the line.

hielo 65 Veteran Poster

when I try to download image ...the file gets corrupted

Have you tried sending the appropriate MIME type for the file. Assuming you are dealing with a JPEG image, try sending header("Content-type: image/jpeg"); instead of header("Content-type: application/octet-stream"); Also, be sure to add exit(); right before the closing ?>

hielo 65 Veteran Poster

in your javascript code, line 66 should be: ajaxRequest.open("GET", "dropdownyear.php" + queryString, true); in dropdownmodel.php, line 12 should be: $opt = "<option value='$Mod'>$Mod</option>";

hielo 65 Veteran Poster

You need to enclose the expression in parenthesis for the back reference to work. Since you need to replace based on your php array, you also need to use the 'e' switch at the end of the regex:

<?php
$str="String of text containing item1 and item2";
$x['item1']="Item 1";
$x['item2']="Item 2";
$str=preg_replace('/(item\d+)/e','$x[$1]',$str);
print $str;
?>
hielo 65 Veteran Poster
hielo 65 Veteran Poster
NOTE: On the steps below
">"  mean "click on"
">>" mean "double click on"


>Start	>Control Panel	>>Administrative Tools	>>Services >>MySQL

Change Startup type to Manual

>Apply
hielo 65 Veteran Poster

whenever you see "Warning: mysql_XXX expects XXX to be resource..." typically it means that whatever query you attempted to execute failed. So replace your line 13 with the following instead to find out what is causing the error: $result = mysql_query($query) or die( mysql_error() );

hielo 65 Veteran Poster

try:

$i = 0;
while($row=mysql_fetch_array($result, MYSQL_NUM)) {
    echo "$row[0]";
   if( !(++$i % 2) )
    {
      echo "<br />";
    }
}
hielo 65 Veteran Poster

I used this but when I puss submit button twice it send same data again,and same data is written twice. I can't solve this.

On the example I posted, you just need to disable the button on the callback function:

<script type="text/javascript">
	$(function(){
		$('#myform').bind('submit',function(){
				$.post('process.php', $("#myform").serialize(), function(data) {
					$('#results').html(data);
                                        $("#Submit").attr("disabled","disabled");
				});
		});
	})
	</script>

...it is working at firefox correctly but it didn't work any others (chrome, opera, İE)...

Never use name="submit" and/or id="submit" on any element, although it is OK if you use an uppercase "S". So change: <input type="submit" id="submit" name="gonder" value="SEND!" ></input> to: <input type="submit" id="Submit" name="gonder" value="SEND!" ></input> and INSTEAD of: $('input:submit').attr("disabled", true); use: $('#Submit').attr("disabled", "disabled");

hielo 65 Veteran Poster

On my previous post (http://www.daniweb.com/forums/post1430495.html#post1430495), the first regex is missing parentheses. It should be: $text = preg_replace('(\s\s+)',' ',preg_replace('(\r\n|\r|\n)',' ',$text));

hielo 65 Veteran Poster

Like I said, look at your scripts (plugins and/or library) to see where this might be happening. Inserting a new line in your actual input is NOT something the browser does.

hielo 65 Veteran Poster

Glad to help.

Regards,
Hielo

PS: Don't forget to mark the thread as solved.

hielo 65 Veteran Poster

Like I said before, the browser will NOT "tamper" with the ACTUAL user input when doing some word wrapping. Meaning it will NOT insert any "symbol" to force the text onto the next line. If anything, it is possible you may have some javascript (perhaps a library or plugin) doing so, in which case you need to revise your own script.

hielo 65 Veteran Poster

Your problem is that you keep using document.write AFTER the page has loaded. You should only use it WHILE the page is still loading. Try creating a div with an id and whatever you intend to put via document.write, instead insert it into the div. Also, on the <a> tag, just use href="#" instead of href="javascript:" - ex:

<html>
<head>
<title>Hello everyone</title>
</head>
<body>
<script type="text/javascript">
window.onload = initAll;
function initAll(){
actRedirect();
}
function actRedirect(){
var actLink = document.getElementById("activeRedirect");
actLink.onclick = redirectNow;
}
function redirectNow(){
 window.setTimeout(function(){window.location.href='http://google.com';}, 5000);
 document.getElementById('target').innerHTML="Please wait, you will be redirect to google soon!";
}
</script>
<div id="target"></div>
<a href="#" id="activeRedirect"> Redirect to Google now.</a>
</body>
</html>
moonknight33 commented: extractly +0
hielo 65 Veteran Poster

Now the textarea will add space before the word that fallen down that you did not enter and this will result in extra space in the text.

That should not be happening. At least the browser will NOT add any space to your textarea. Visually, the browser should handle the "wrapping" for you, but would NOT add an actual space character to the user input.

Even if that were the case(not due to the browser but by some client-side scripting) you can just look for sequences of back to back spaces and replace them: $text = preg_replace('\s\s+',' ',preg_replace('(\r\n|\r|\n)',' ',$text));

hielo 65 Veteran Poster

read comments in code below:

//queue that keeps track of which requests are currently active
var ajaxRequest=[];

//this function is where you would be making your ajax request
function requestPage(url)
{
  //now see if url is within ajaxRequest. If so, then just return
  var tempQ = ',' + ajaxRequest.join(",") + ',';
  if( tempQ.indexOf(url) > -1 )
  {
   return false;
  }

  //if you make it here, there is no ongoing request to the specified url
  //so be sure to add it to the queue
  ajaxRequest[ajaxRequest.length]=url;

  /* here is the rest of your code that is supposed to emit the ajax request
     I expect you to have an onreadystatechange function somewhere here. You need to make sure you remove the url from the queue when the request has completed - ex: UNSTESTED */
  http.onreadystatechange=function(){
    if( http.readystate==4 )
    {
       if( http.status==200 )
       {
          //request was successful
          ...
       }
       tempQ = tempQ.replace(',' + url + ',' , '');
       ajaxRequest=tempQ.substring(1,tempQ.length-1).split(",");
    }
  };
}
hielo 65 Veteran Poster

You can use an external/remote SMTP server (Ex: gmail, as suggested above). Go to:
http://phpmailer.worxware.com/

and get a copy of the PHPMailer class. Be sure to check:
Products -> PHPMailer -> PHPMailer Examples -> Adv. SMTP Examples

hielo 65 Veteran Poster

Let me clarify. Typically in Unix/Linux systems, when you press the Enter key it produces \n character. In Macs, you get \r, while in Windows you get \r\n (TWO characters even though you pressed one key - this is likely your problem). I was trying to get you to revised your code to see if you are already changing \r and/or \n to single space, in which case it explains why you were ending up with back to back spaces.

You can simply replace \r\n to a single \n. If you are actually insterested in NOT having newlines at all and are infact converting them to spaces you can just do: $text = preg_replace('(\r\n|\r|\n)',' ',$text); If you do not want the newlines changed to spaces then use: $text = preg_replace('(\r\n|\r|\n)','',$text);

hielo 65 Veteran Poster
var theDiv = document.getElementById("test");
//the div's content
alert( theDiv.innerHTML );

/* get the paragraph - NOTE: getElementsByTagName returns an array of references to the elements that match the tag specified. In this case "p". Arrays are zero indexed, so the first P element is at index zero. If you had more than one P within the div, then the second P would be at index 1, etc. */
var theP=theDiv.getElementsByTagName("p")[0];

//the content of the paragraph
alert( theP.innerHTML );

//removing the theDiv from the page
theDiv.parentNode.removeChild( theDiv );
hielo 65 Veteran Poster

Change line 14 from this: clickLink.onClick = promptWhatsName(); to this: clickLink.onclick = promptWhatsName;

hielo 65 Veteran Poster

you completely missed my point. I was trying to get you to see if you already had code that was already replacing \n with ' ' (double spaces) in which case you should have changed that to a single space or perhaps an empty string.

hielo 65 Veteran Poster

then when I send the paragraph to my mobile phone, I get 162 characters

see if you have a javascript onsubmit function that changes carriage returns and/or new lines to spaces before submitting.

Also, check (for the same thing mentioned above) on the server script to which you are posting/sending the information to.

hielo 65 Veteran Poster

this:

$(document).ready(function(){
   $(".productSelect").click(function() {
     alert( this.innerHTML );
   });
});

is equivalent to this:

$(document).ready(function(){
   $(".productSelect").bind('click',function() {
     alert( this.innerHTML );
   });
});

but bind will "attach/trigger" that anonymous function upon document.ready ONLY to already existing elements with class="productSelect".

So, the elements that you are adding via ajax with class="productSelect" do not exist upon page load (document.ready). They exist LATER on AFTER the bind has done executing, so they will NOT trigger that alert. Instead of bind() you need to use live(). live() will "keep an eye" for dynamically created elements and if needed will attach the necessary anonymous function:

$(document).ready(function(){
   $(".productSelect").live('click',function() {
     alert( this.innerHTML );
   });
});
hielo 65 Veteran Poster

It sounds like you have:

if ($rank < "Boss, Supreme Boss, Kingpin, Don, Godfather"){ 
  echo "You have to be ranked atleast Boss to kill";
}
//code that "kills" follows here
...

You need to wrap the code that kills in an else clause:

if ($rank < "Boss, Supreme Boss, Kingpin, Don, Godfather"){ 
  echo "You have to be ranked atleast Boss to kill";
}
else
{
  //code that "kills" follows here
  ...
}

OR simply exit the script immediately from the if clause:

if ($rank < "Boss, Supreme Boss, Kingpin, Don, Godfather"){ 
  echo "You have to be ranked atleast Boss to kill";
  exit;
}
hielo 65 Veteran Poster

Where should be at the end:

$query = "SELECT COUNT(*) as num FROM $tableName  where headm='" . mysql_real_escape_string($_GET['chead']) . "'";
hielo 65 Veteran Poster

(you can try it yourself @ http://www.birdnest.org/joshid2/bgrades.html -->username: student1 --->password: AAAAAAAA).

a. I went to that page and it has no field to enter the username
b. Based on your username and password arrays, student1 corresponds with password cNmeKFBc, NOT AAAAAAAA. In other words,
item 0 in $Ukeys should correspond to item 0 in $Pkeys
item 1 in $Ukeys should correspond to item 1 in $Pkeys
...
item 31 in $Ukeys should correspond to item 31 in $Pkeys

hielo 65 Veteran Poster

On line 67, you probably meant to write $var_Ulist = explode("\n",$var_data);

hielo 65 Veteran Poster

somewhere in your code you probably have a DB class (ex: $db = new DB(...);/* or something similar */ ). Does that class have a method that will let you know if any records were returned? It would help to see the definition of your custom class.

hielo 65 Veteran Poster

you can also try: echo "<span style='padding-left:2em;'>Successfuly sent</span>"; If needed, adjust 2em until it is centered.

hielo 65 Veteran Poster

assuming you are using MySQL as your Database, as soon as you execute your INSERT statement, use the mysql_insert_id() function -
http://us3.php.net/manual/en/function.mysql-insert-id.php

to retrieve the auto_number.Then use that number to INSERT it into your AF table:

...

$sql="INSERT INTO `room`(...) VALUES(...)";

$result = mysql_query($sql) or die( mysql_error() );

$Room_No=mysql_insert_id();

$sql="INSERT INTO `AF`(`Room_No`) VALUES( $Room_No)";
mysql_query($sql) or die( mysql_error() );
...