How to Encode / Decode through a form
06-05-2008, 03:32 PM
|
How to Encode / Decode through a form
|
Posts: 34
Name: Jin
Location: Bangkok
|
How can I except different languages through a form and store it in a MySQL database to be displayed on the website after?
I have 2 databases with 2 different scripts, one database can take multiple languages and store, display it with no problem but the other can not, this tells me since both databases and scripts are on the same server the difference has to be in the form submission method but I have looked through the files and do not see anything that would tell me how one is doing it and the other isn't.
An example is if I want to submit Thai language in a form สวัสดีครับ the encode would look like this in a database
PHP Code:
สวัสดีครับ
Then the output to the page would get decoded back to the recognizable Thai language.
Anybody can point me to any information on how this can be done?
I am using MySQL 5+ UTF-8
|
|
|
|
06-05-2008, 04:22 PM
|
Re: How to Encode / Decode through a form
|
Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
|
Errm Thai is a multi-byte language you'd need UTF-16. Also make sure your files are saved in and have the encoding listed as, UTF-16. Can I see both your scripts though?
__________________
PHP Code:
<?php echo "Hello World"; ?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
|
|
|
|
06-05-2008, 04:57 PM
|
Re: How to Encode / Decode through a form
|
Posts: 34
Name: Jin
Location: Bangkok
|
Thats what I am trying to find out how to do, how do I save it with encoding listed? Not sure what I should be looking for or what needs to be changed.
What is it that you want to see in the scripts? I can post some code here if you let me know what it is that you will need to see?
Thanks
Quote:
|
Errm Thai is a multi-byte language you'd need UTF-16. Also make sure your files are saved in and have the encoding listed as, UTF-16. Can I see both your scripts though?
|
|
|
|
|
06-05-2008, 07:05 PM
|
Re: How to Encode / Decode through a form
|
Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-16">
Add that right after the head tag. With your scripts I just want to see the form itself and the section that holds the insert statement to see if maybe I can spot anything going on.
__________________
PHP Code:
<?php echo "Hello World"; ?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
|
|
|
|
06-05-2008, 10:41 PM
|
Re: How to Encode / Decode through a form
|
Posts: 265
Name: Lucas
|
Take a look at the <form> tag on both pages and make sure they are exactly the same
|
|
|
|
06-06-2008, 03:00 AM
|
Re: How to Encode / Decode through a form
|
Posts: 34
Name: Jin
Location: Bangkok
|
Both scripts have the same meta tag in them as the one below. If I am not mistaken this will not help in a form submission but it tells the search engines what language your page is in.
Code:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
This is the form that does not work
HTML Code:
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" name="form123" id="form123" onSubmit="return validate(this);">
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="2" class="onepxtable">
<tr class="titlestyle">
<td colspan="3"> Bidding for <font class="red"><strong><?php echo $sbrow_pro["sb_title"] ?></strong></font></td>
</tr><?php if(!isset($_SESSION["sbprj_userid"]))
{ ?>
<tr valign="top">
<td width="40%" align="right" class="innertablestyle"><font class="normal"><strong>Username
</strong></font></td>
<td><font class="red">*</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="2">
<input name="sb_username" type="text" id="sb_username" value="<?php echo $sb_username; ?>" size="30" maxlength="30">
</font></td>
</tr>
<tr valign="top">
<td height="24" align="right" class="innertablestyle"><font class="normal"><strong>Password</strong></font></td>
<td><font class="red">*</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="2">
<input name="sb_password" type="password" id="sb_password" size="30" maxlength="30" >
</font></td>
</tr><?php } //end if if(!isset($_SESSION["sbprj_userid"]))
?>
<tr valign="top">
<td width="40%" align="right" class="innertablestyle"><font class="normal"><strong>Bid
Amount </strong></font></td>
<td width="6"><font class="red">*</font></td>
<td width="60%"><font class="normal"><?php echo $sb_fee_currency; ?></font><font face="Arial, Helvetica, sans-serif" size="2">
<input name="sb_bidamt" type="text" id="sb_bidamt" value="<?php echo $sb_bidamt; ?>" size="15" maxlength="30">
</font></td>
</tr>
<tr valign="top">
<td height="24" align="right" class="innertablestyle"><font class="normal"><strong>Completion
Time </strong></font></td>
<td><font class="red">*</font></td>
<td><font class="normal">
<input name="sb_timelimit" type="text" id="sb_timelimit" value="<?php echo $sb_timelimit; ?>" size="15" maxlength="30" >
Days </font></td>
</tr>
<tr valign="top">
<td height="24" align="right" class="innertablestyle"><font class="normal"><strong>Comments</strong></font></td>
<td><font class="red">*</font></td>
<td><font class="smalltext">
<textarea name="sb_comments" cols="40" rows="8" id="sb_comments"><?php echo $sb_comments; ?></textarea>
<?php if($sb_comment_len>0) {?>
<br>
<font class="smalltext">not more than <?php echo $sb_comment_len; ?>
characters</font>
<?php } //end if ?>
</font></td>
</tr>
<tr valign="top">
<td align="right" class="innertablestyle"> </td>
<td> </td>
<td><input name="sb_notify" type="checkbox" id="sb_notify" value="yes" <?php echo($sb_notify=='yes')?'checked':''?>>
<font class="normal">Notify me.</font></td>
</tr>
<tr valign="top">
<td align="right" class="innertablestyle"> </td>
<td> </td>
<td><input name="submit" type="submit" value="Bid Now">
<input name="sb_id" type="hidden" id="sb_id" value="<?php echo $sb_id?>"></td>
</tr>
</table>
</form>
This is the form that does work
PHP Code:
echo '<form method="POST" action="project.php"> <input type="hidden" name="bid" value="' . $bid . '"> <big><b>Bid on Project: ' . SQLact("result", $result,0,"project") . '</b></big> <p> <p> <strong>Username:</strong><br> <small>(<a href="' . $siteurl . '/freelancers.php?new=user">Click here to signup</a>)</small> <br> <input type="text" name="username" value="' . $username . '" size="15"> <p> <strong>Password:</strong><br> <input type="password" name="password" value="' . $password . '" size="15"> <p> <strong>Your bid for the total project:</strong><br>'; if (SQLact("result", $result,0,"budgetmin") == "" && SQLact("result", $result,0,"budgetmax") !== "") { echo '<small>Project budget maximum is ' . $currencytype . '' . $currency . '' . SQLact("result", $result,0,"budgetmax") . '</small><br>'; } else if (SQLact("result", $result,0,"budgetmin") !== "" && SQLact("result", $result,0,"budgetmax") == "") { echo '<small>Project budget minimum is ' . $currencytype . '' . $currency . '' . SQLact("result", $result,0,"budgetmin") . '</small><br>'; } else if (SQLact("result", $result,0,"budgetmin") !== "" && SQLact("result", $result,0,"budgetmax") !== "") { echo '<small>Project budget is ' . $currencytype . '' . $currency . '' . SQLact("result", $result,0,"budgetmin") . ' - ' . $currencytype . '' . $currency . '' . SQLact("result", $result,0,"budgetmax") . '</small><br>'; } echo $currencytype . '' . $currency . '<input type="text" name="bidamount" maxlength="6" size="6"> <p> <strong>In how many days can you deliver a completed project?</strong><br> <small>'; $secondsPerDay = ((24 * 60) * 60); $timeStamp = time(); $daysUntilExpiry = SQLact("result", $result,0,"expires"); $expiry = $timeStamp + ($daysUntilExpiry * $secondsPerDay); $date = getdate($expiry); $month = $date["mon"]; $day = $date["mday"]; $year = $date["year"]; $expiryDate = $month . '/' . $day . '/' . $year; echo '(The user wants the project completed by ' . $expiryDate. ', which is '; if ($expiry==0) { echo 'in less than one day.)'; } else if ($expiry>=1) { echo 'in ' . ( $expiry - $timeStamp ) / $secondsPerDay . ' day'; if ($expiry==1) {} else { echo 's'; } echo '.)'; } else { echo 'expired.)'; } echo '</small> <br> <input type="text" name="days" maxlength="3" value="' . ( $expiry - $timeStamp ) / $secondsPerDay . '" size="5"> Day(s) <p> <strong>Provide the details of your bid (optional):</strong><br> <textarea rows="8" name="details" cols="52"></textarea> <p> <input type="checkbox" name="outbid" value="y"> Notify me by e-mail if someone bids lower than me on this project. <p> <input type="submit" value="Place Bid" name="submit"> </form>';
|
|
|
|
06-06-2008, 06:19 PM
|
Re: How to Encode / Decode through a form
|
Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
|
What's the PHP that processes them both?
__________________
PHP Code:
<?php echo "Hello World"; ?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
|
|
|
|
06-10-2008, 01:54 AM
|
Re: How to Encode / Decode through a form
|
Posts: 34
Name: Jin
Location: Bangkok
|
Sorry for late reply
This is the complete form that does not work
PHP Code:
<? if(!isset($_SESSION["sbprj_userid"])) { $sb_username=''; $sb_password=''; $sb_empty=false; //used to check whether some input was there or not if( !isset($_REQUEST["sb_username"]) || ($_REQUEST["sb_username"]=='') ) { $sb_empty=true; $errs[$errcnt]="Username must be provided"; $errcnt++; } else $sb_username=$_REQUEST["sb_username"]; if( !isset($_REQUEST["sb_password"]) || ($_REQUEST["sb_password"]=='') ) { $sb_empty=true; $errs[$errcnt]="Password must be provided"; $errcnt++; } else $sb_password=$_REQUEST["sb_password"]; if(!get_magic_quotes_gpc()) { $sb_username=str_replace("$","\$",addslashes($sb_username)); $sb_password=str_replace("$","\$",addslashes($sb_password)); } else { $sb_username=str_replace("$","\$",$sb_username); $sb_password=str_replace("$","\$",$sb_password); } include_once'loginfun.php'; $sb_userid=loginuser($sb_username,$sb_password,false); //third arg is cool chk it if( !$sb_empty && ($sb_userid == 0 ) ) { $errs[$errcnt]="Webmaster can't bid for the project"; $errcnt++; } elseif( !$sb_empty && ($sb_userid < 1) ) { $errs[$errcnt]="Username/Password is incorrect"; $errcnt++; } } //end if !isset($_SESSION["sbprj_userid"]) else { include_once'programmer_include.php'; $sb_userid=$_SESSION["sbprj_userid"]; if(!get_magic_quotes_gpc()) $sb_username=str_replace("$","\$",addslashes($_SESSION["sbprj_username"])); else $sb_username=str_replace("$","\$",$_SESSION["sbprj_username"]); } $sb_notify='no'; if( isset($_REQUEST["sb_notify"]) && ($_REQUEST["sb_notify"]=='yes') ) $sb_notify='yes'; if( !isset($_REQUEST["sb_bidamt"]) || !is_numeric($_REQUEST["sb_bidamt"]) || ($_REQUEST["sb_bidamt"] <= 0) ) { $errs[$errcnt]="Bid Amount must be a non-zero positive number"; $errcnt++; } else $sb_bidamt=$_REQUEST["sb_bidamt"]; if( !isset($_REQUEST["sb_timelimit"]) || !is_numeric($_REQUEST["sb_timelimit"]) || ($_REQUEST["sb_timelimit"] < 0) ) { $errs[$errcnt]="Completion Time must be a positive number"; $errcnt++; } else $sb_timelimit=$_REQUEST["sb_timelimit"]; /* $NULLNOTE|ZY-|WST| if(!isset($kvozewdva)) { die();} */ if( !isset($_REQUEST["sb_comments"]) || ( strlen(trim($_REQUEST["sb_comments"])) == 0) ) { $errs[$errcnt]="Comments must be provided"; $errcnt++; } elseif(preg_match ("/[&<>]/", $_REQUEST["sb_comments"])) { $errs[$errcnt]="Comments must not contain any special character i.e. < > &"; $errcnt++; } elseif( ($sb_comment_len > 0) && (strlen(trim($_REQUEST["sb_comments"])) > $sb_comment_len) ) { $errs[$errcnt]="Comments can't be more than $sb_comment_len characters long"; $errcnt++; } else $sb_comments=trim($_REQUEST["sb_comments"]); if($errcnt==0) { if(!get_magic_quotes_gpc()) { $sb_comments=str_replace("$","\$",addslashes($_REQUEST["sb_comments"])); } else { $sb_comments=str_replace("$","\$",$_REQUEST["sb_comments"]); } if($sb_bid_approval=='auto') { $sb_approved_insert='yes'; $sb_approved="yes"; $msg="Your bid has been placed"; } else { $sb_approved_insert='new'; $sb_approved="no"; $msg="Your bid has been sent for admin approval"; } $sb_biddate=date("YmdHis",time()); $sbq_bid_chk="select * from sbprj_bids where sb_project_id=$sb_id and sb_userid=$sb_userid"; $sbrow_bid_chk=mysql_fetch_array(mysql_query($sbq_bid_chk)); if($sbrow_bid_chk) { if($sbrow_bid_chk["sb_approved"]=='yes') { $sbq_bid="update`sbprj_bids` set sb_bidamt=$sb_bidamt, sb_timelimit=$sb_timelimit, sb_comments='$sb_comments', sb_biddate=$sb_biddate, sb_approved='$sb_approved', sb_notify='$sb_notify' where sb_id=".$sbrow_bid_chk["sb_id"]; } else { $sbq_bid="update`sbprj_bids` set sb_bidamt=$sb_bidamt, sb_timelimit=$sb_timelimit, sb_comments='$sb_comments', sb_biddate=$sb_biddate, sb_notify='$sb_notify' where sb_id=".$sbrow_bid_chk["sb_id"]; $msg="Your bid has been sent for admin approval"; } } else $sbq_bid="insert into `sbprj_bids` (sb_project_id, sb_userid, sb_username, sb_bidamt, sb_timelimit, sb_comments, sb_biddate, sb_approved, sb_notify) values ($sb_id, $sb_userid, '$sb_username', $sb_bidamt, $sb_timelimit, '$sb_comments', $sb_biddate, '$sb_approved_insert', '$sb_notify')"; //echo $sbq_bid; //die(); /* $NULLNOTE|ZY-|WST| if(!isset($kvozewdva)) { die();} */ mysql_query($sbq_bid); if(mysql_affected_rows()>0) { $sbq_bid1="select * from `sbprj_bids` where sb_project_id=$sb_id and sb_userid=$sb_userid"; $sbrow_bid1=mysql_fetch_array(mysql_query($sbq_bid1)); //////---------sendin' mail to adm if approval type is admin if( $sbrow_bid1["sb_approved"]<>'yes' )//$sbrow_con["sb_bid_approval"]=="admin") //for mailing { $sbq_mem="select * from sbprj_members where sb_id=$sb_userid"; $sbrow_mem=mysql_fetch_array(mysql_query($sbq_mem)); // $sbrow_con=mysql_fetch_array(mysql_query("select * from sbprj_config")); $sb_null_char=$sbrow_con["sb_null_char"]; $sb_site_root=$sbrow_con["sb_site_root"]; $sb_admin_email=$sbrow_con["sb_admin_email"]; $sb_project_url=$sb_site_root."/view_project.php?sb_id=$sb_id"; $sql = "SELECT * FROM sbprj_mails where sb_mailid=6" ; $rs_query=mysql_query($sql); // $login_url=$sb_site_root."/signin.php"; if ( $rs=mysql_fetch_array($rs_query) )// if mail { if($rs["sb_status"]=="yes") { $from=$rs["sb_fromid"]; $to = $sb_admin_email; $subject =$rs["sb_subject"]; $body=str_replace("%email%", $sbrow_mem["sb_email_addr"],str_replace("%password%",$sb_null_char, str_replace("%fname%", $sbrow_mem["sb_firstname"],str_replace("%username%", $sbrow_mem["sb_username"], $rs["sb_mail"]) ))); $body=str_replace("%signup_url%",$sb_null_char,str_replace("%login_url%",$sb_null_char,$body)); $body=str_replace("%project_id%",$sb_id,str_replace("%project_title%",$sbrow_pro["sb_title"],str_replace("%project_url%",$sb_project_url,str_replace("%bid_amount%",$sb_fee_currency." ".$sb_bidamt,$body)))); $header="From:" . $from . "\r\n" ."Reply-To:". $from ; if(isset($rs["sb_html_format"])&&($rs["sb_html_format"]=="yes")) { $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-type: text/html; charset=iso-8859-1\r\n"; } // echo "--from:-$from----to:-$to---sub:-$subject----head:-$header----"; // echo "<pre>$body</pre>"; // die(); /* $NULLNOTE|ZY-|WST| if(!isset($kvozewdva)) { die();} */ @mail($to,$subject,$body,$header); }// end if status is on }// end if mail } //end if $config["sb_mem_approval"]=="admin" for mailing else { //mail to member //////------------- $sbq_mem="select * from sbprj_members where sb_id=$sb_userid"; $sbrow_mem=mysql_fetch_array(mysql_query($sbq_mem)); // $sbrow_con=mysql_fetch_array(mysql_query("select * from sbprj_config")); $sb_null_char=$sbrow_con["sb_null_char"]; $sb_site_root=$sbrow_con["sb_site_root"]; $sb_admin_email=$sbrow_con["sb_admin_email"]; $sb_project_url=$sb_site_root."/view_project.php?sb_id=$sb_id"; $sb_login_url=$sb_site_root."/signin.php"; $sql = "SELECT * FROM sbprj_mails where sb_mailid=7" ; $rs_query=mysql_query($sql); // $login_url=$sb_site_root."/signin.php"; if ( $rs=mysql_fetch_array($rs_query) )// if mail { if($rs["sb_status"]=="yes") { $from=$rs["sb_fromid"]; $to = $sbrow_mem["sb_email_addr"]; $subject =$rs["sb_subject"]; $body=str_replace("%email%", $sbrow_mem["sb_email_addr"],str_replace("%password%",$sb_null_char, str_replace("%fname%", $sbrow_mem["sb_firstname"],str_replace("%username%", $sbrow_mem["sb_username"], $rs["sb_mail"]) ))); $body=str_replace("%signup_url%",$sb_null_char,str_replace("%login_url%",$sb_login_url,$body)); $body=str_replace("%project_id%",$sb_id,str_replace("%project_title%",$sbrow_pro["sb_title"],str_replace("%project_url%",$sb_project_url,str_replace("%bid_amount%",$sb_fee_currency." ".$sb_bidamt,$body)))); $header="From:" . $from . "\r\n" ."Reply-To:". $from ; if(isset($rs["sb_html_format"])&&($rs["sb_html_format"]=="yes")) { $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-type: text/html; charset=iso-8859-1\r\n"; } // echo "--from:-$from----to:-$to---sub:-$subject----head:-$header----"; // echo "<pre>$body</pre>"; // die(); @mail($to,$subject,$body,$header); }// end if status is on }// end if mail /////------------mailing min bid notification $sql = "SELECT * FROM sbprj_mails where sb_mailid=13" ; $rs_query=mysql_query($sql); // $login_url=$sb_site_root."/signin.php"; if ( $rs=mysql_fetch_array($rs_query) )// if mail { if($rs["sb_status"]=="yes") { $sbq30_bids="select * from sbprj_bids where sb_project_id=$sb_id and sb_notify='yes' and sb_bidamt>=$sb_bidamt and sb_userid<>$sb_userid"; //notify all except current user $sbrs30_bids=mysql_query($sbq30_bids); $sb_user_id_list="-1"; while($sbrow30_bids=mysql_fetch_array($sbrs30_bids)) $sb_user_id_list.=",".$sbrow30_bids["sb_userid"]; $sbq31_mem="select * from sbprj_members where sb_id in ($sb_user_id_list)"; $sbrs31_mem=mysql_query($sbq31_mem); while($sbrow31_mem=mysql_fetch_array($sbrs31_mem)) { $from=$rs["sb_fromid"]; $to = $sbrow31_mem["sb_email_addr"]; $subject =$rs["sb_subject"]; $body=str_replace("%email%", $sbrow31_mem["sb_email_addr"],str_replace("%password%",$sb_null_char, str_replace("%fname%", $sbrow31_mem["sb_firstname"],str_replace("%username%", $sbrow31_mem["sb_username"], $rs["sb_mail"]) ))); $body=str_replace("%signup_url%",$sb_null_char,str_replace("%login_url%",$sb_login_url,$body)); $body=str_replace("%project_id%",$sb_id,str_replace("%project_title%",$sbrow_pro["sb_title"],str_replace("%project_url%",$sb_project_url,str_replace("%bid_amount%",$sb_fee_currency." ".$sb_bidamt,str_replace("%programmer_username%",$sb_username,$body))))); /* $NULLNOTE|ZY-|WST| if(!isset($kvozewdva)) { die();} */ $header="From:" . $from . "\r\n" ."Reply-To:". $from ; if(isset($rs["sb_html_format"])&&($rs["sb_html_format"]=="yes")) { $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-type: text/html; charset=iso-8859-1\r\n"; } // echo "--from:-$from----to:-$to---sub:-$subject----head:-$header----"; // echo "<pre>$body</pre>"; // die(); @mail($to,$subject,$body,$header); //////-------------end mailing min bid notification } //end while }// end if status is on }// end if mail } //end else if $config["sb_mem_approval"]=="admin" for mailing ////////////--------------------end mail header("Location: gen_confirm_mem.php?err_suc=view_project&sb_id=$sb_id&errmsg=".urlencode($msg)); die(); } else { header("Location: gen_confirm_mem.php?err=bid_now&sb_id=$sb_id&errmsg=".urlencode("Some error occured, unable to place bid.")); die(); } } //end if-errcnt==0 } //end if count-post else { $sb_username=''; $sb_password=''; $sb_bidamt=''; $sb_timelimit=''; $sb_comments=''; $sb_notify=''; } function main() { global $sb_id, $sbrow_pro, $errs, $errcnt, $sb_username, $sb_password, $sb_bidamt, $sb_timelimit, $sb_comments, $sb_notify, $sb_comment_len, $sb_fee_currency, $sb_fee_currency_name; //IF SOME FORM WAS POSTED DO VALIDATION if (count($_POST)>0) { if ( $errcnt<>0 ) { ?> <table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="errorstyle"> <tr> <td colspan="2"><strong> Your Request cannot be processed due to following Reasons</strong></td> </tr> <tr height="10"> <td colspan="2"></td> </tr> <? for ($i=0;$i<$errcnt;$i++) { ?> <tr valign="top"> <td width="6%"> <?php echo $i+1;?></td> <td width="94%"><?php echo $errs[$i]; ?></td> </tr> <? } ?> </table> <? } } ?> <SCRIPT language=javascript> //<!-- function validate(form) { <?php if( !isset($_SESSION["sbprj_userid"]) ) { ?> if( form.sb_username.value == "" ) { alert("Please specify Username"); form.sb_username.focus(); return(false); } if( form.sb_password.value == "" ) { alert("Please specify Password"); form.sb_password.focus(); return(false); } <?php } //end if <?php if($sbuser_type==2) ?> if ( (form.sb_bidamt.value == "") || (isNaN(form.sb_bidamt.value) || form.sb_bidamt.value<=0) ) { alert('Please specify positive non-zero numeric value for Bid Amount.'); form.sb_bidamt.focus(); form.sb_bidamt.select(); return false; } if ( (form.sb_timelimit.value == "") || (isNaN(form.sb_timelimit.value) || form.sb_timelimit.value<0) ) { alert('Please specify positive numeric value for Completion Time.'); form.sb_timelimit.focus(); form.sb_timelimit.select(); return false; } if( form.sb_comments.value == "" ) { alert("Please specify Comments"); form.sb_comments.focus(); return(false); } else if(form.sb_comments.value.match(/[&<>]+/)) { alert("Please remove special characters from Comments i.e. & < >"); form.sb_comments.focus(); form.sb_comments.select(); return(false); } else if( <?php echo $sb_comment_len ?> > 0 && form.sb_comments.value.length > <?php echo $sb_comment_len ?>) { alert("Comments must not exceed <?php echo $sb_comment_len ?> characters"); form.sb_comments.focus(); form.sb_comments.select(); return(false); } return true; } // --> </SCRIPT> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" name="form123" id="form123" onSubmit="return validate(this);"> <table width="90%" border="0" align="center" cellpadding="2" cellspacing="2" class="onepxtable"> <tr class="titlestyle"> <td colspan="3"> Bidding for <font class="red"><strong><?php echo $sbrow_pro["sb_title"] ?></strong></font></td> </tr><?php if(!isset($_SESSION["sbprj_userid"])) { ?> <tr valign="top"> <td width="40%" align="right" class="innertablestyle"><font class="normal"><strong>Username </strong></font></td> <td><font class="red">*</font></td> <td><font face="Arial, Helvetica, sans-serif" size="2"> <input name="sb_username" type="text" id="sb_username" value="<?php echo $sb_username; ?>" size="30" maxlength="30"> </font></td> </tr> <tr valign="top"> <td height="24" align="right" class="innertablestyle"><font class="normal"><strong>Password</strong></font></td> <td><font class="red">*</font></td> <td><font face="Arial, Helvetica, sans-serif" size="2"> <input name="sb_password" type="password" id="sb_password" size="30" maxlength="30" > </font></td> </tr><?php } //end if if(!isset($_SESSION["sbprj_userid"])) ?> <tr valign="top"> <td width="40%" align="right" class="innertablestyle"><font class="normal"><strong>Bid Amount </strong></font></td> <td width="6"><font class="red">*</font></td> <td width="60%"><font class="normal"><?php echo $sb_fee_currency; ?></font><font face="Arial, Helvetica, sans-serif" size="2"> <input name="sb_bidamt" type="text" id="sb_bidamt" value="<?php echo $sb_bidamt; ?>" size="15" maxlength="30"> </font></td> </tr> <tr valign="top"> <td height="24" align="right" class="innertablestyle"><font class="normal"><strong>Completion Time </strong></font></td> <td><font class="red">*</font></td> <td><font class="normal"> <input name="sb_timelimit" type="text" id="sb_timelimit" value="<?php echo $sb_timelimit; ?>" size="15" maxlength="30" > Days </font></td> </tr> <tr valign="top"> <td height="24" align="right" class="innertablestyle"><font class="normal"><strong>Comments</strong></font></td> <td><font class="red">*</font></td> <td><font class="smalltext"> <textarea name="sb_comments" cols="40" rows="8" id="sb_comments"><?php echo $sb_comments; ?></textarea> <?php if($sb_comment_len>0) {?> <br> <font class="smalltext">not more than <?php echo $sb_comment_len; ?> characters</font> <?php } //end if ?> </font></td> </tr> <tr valign="top"> <td align="right" class="innertablestyle"> </td> <td> </td> <td><input name="sb_notify" type="checkbox" id="sb_notify" value="yes" <?php echo($sb_notify=='yes')?'checked':''?>> <font class="normal">Notify me if someone bids lower than my bid.</font></td> </tr> <tr valign="top"> <td align="right" class="innertablestyle"> </td> <td> </td> <td><input name="submit" type="submit" value="Bid Now"> <input name="sb_id" type="hidden" id="sb_id" value="<?php echo $sb_id?>"></td> </tr> </table> </form> <? } ?>
|
|
|
|
06-10-2008, 01:54 AM
|
Re: How to Encode / Decode through a form
|
Posts: 34
Name: Jin
Location: Bangkok
|
This is the complete form that does work
PHP Code:
<?php require "vars.php"; require "cron.php"; if ($id && $id !== "") { include ("header.php"); $result = SQLact("query", "SELECT * FROM freelancers_projects WHERE id='$id'"); if (SQLact("num_rows", $result)==0) { echo 'No project was found with that ID number.'; } else { ?> <b><big>Thai Freelancers Project: <? echo SQLact("result", $result,0,"project"); ?></big></b><? if (SQLact("result", $result,0,"special") == "featured") { echo ' <a href="' . $siteurl . '/featured.php"><img src="' . $siteurl . '/images/featured.gif" alt="Featured Project!" border=0></a>'; } $secondsPerDay9 = ((24 * 60) * 60); $timeStamp9 = time(); $daysUntilExpiry9 = SQLact("result", $result,0,"expires"); $getdat9 = $timeStamp9 + ($daysUntilExpiry9 * $secondsPerDay9); $thedat9 = $getdat9-$timeStamp9; $realdat9 = round($thedat9/((24 * 60) * 60)); $explod9 = explode('-', $projectudays); for ($i9=0;$i9<count($explod9);$i9++) { if ($realdat9==$explod9[$i9]) { echo ' <img src="' . $siteurl . '/images/urgent.gif" alt="Urgent!" border=0>'; } } ?><br><b>ID:</b> <? echo $id; ?><p> <?php if (SQLact("result", $result,0,"status") == "cancelled") { echo '(Cancelled Project)<p>'; } else if (SQLact("result", $result,0,"status") == "closed") { echo '<b>Chosen ' . $freelancer . ':</b> <a href="' . $siteurl . '/freelancers.php?viewprofile=' . SQLact("result", $result,0,"chosen") . '">' . SQLact("result", $result,0,"chosen") . '</a>'; $result2 = SQLact("query", "SELECT * FROM freelancers_programmers WHERE username='" . SQLact("result", $result,0,"chosen") . "'"); if (SQLact("result", $result2,0,"special") == "user") { echo ' <a href="' . $siteurl . '/aboutspecial.php"><img src="' . $siteurl . '/images/special.gif" alt="Special User" border=0></a>'; } } ?> <table border="<? echo $tableborder; ?>" width="100%" cellpadding="<? echo $tablecellpa; ?>" cellspacing="<? echo $tablecellsp; ?>"> <tr> <td bgcolor=<? echo $tablecolor1; ?> valign=top><b>Status:</td> <td width="80%" bgcolor=<? echo $tablecolor1; ?> valign=top> <?php echo SQLact("result", $result,0,"status"); if (SQLact("result", $result,0,"status") == "cancelled" || SQLact("result", $result,0,"status") == "closed") { echo ' (No bidding.)'; } else if (SQLact("result", $result,0,"status") == "frozen") { echo ' (No bidding. Waiting for action from project owner.)'; } $secondsPerDay29 = ((24 * 60) * 60); $timeStamp29 = time(); $daysUntilExpiry29 = SQLact("result", $result,0,"expires"); $getdat29 = $timeStamp29 + ($daysUntilExpiry29 * $secondsPerDay29); $thedat29 = $getdat29-$timeStamp29; $realdat29 = round($thedat29/((24 * 60) * 60)); $explod29 = explode('-', $projectudays); for ($i29=0;$i29<count($explod29);$i29++) { if ($realdat29==$explod29[$i29]) { echo ' <img src="' . $siteurl . '/images/urgent.gif" alt="Urgent!" border=0>'; } } ?> </td> </tr> <tr> <td bgcolor=<? echo $tablecolor2; ?> valign=top><b>Budget:</td> <td bgcolor=<? echo $tablecolor2; ?> valign=top> <?php if (SQLact("result", $result,0,"budgetmin") == "" && SQLact("result", $result,0,"budgetmax") !== "") { echo 'Max. ' . $currencytype . '' . $currency . '' . SQLact("result", $result,0,"budgetmax"); } else if (SQLact("result", $result,0,"budgetmin") !== "" && SQLact("result", $result,0,"budgetmax") == "") { echo 'Min. ' . $currencytype . '' . $currency . '' . SQLact("result", $result,0,"budgetmin"); } else if (SQLact("result", $result,0,"budgetmin") !== "" && SQLact("result", $result,0,"budgetmax") !== "") { echo $currencytype . '' . $currency . '' . SQLact("result", $result,0,"budgetmin") . ' - ' . $currencytype . '' . $currency . '' . SQLact("result", $result,0,"budgetmax"); } ?> </td> </tr> <tr> <td bgcolor=<? echo $tablecolor1; ?> valign=top><b>Created:</td> <td bgcolor=<? echo $tablecolor1; ?> valign=top> <? echo SQLact("result", $result,0,"creation") . ' ' . SQLact("result", $result,0,"ctime"); ?> </td> </tr> <tr> <td bgcolor=<? echo $tablecolor2; ?> valign=top><b>Delivery Date:</td> <td bgcolor=<? echo $tablecolor2; ?> valign=top> <?php $secondsPerDay = ((24 * 60) * 60); $timeStamp = time(); $daysUntilExpiry = SQLact("result", $result,0,"expires"); $expiry = $timeStamp + ($daysUntilExpiry * $secondsPerDay); $date = getdate($expiry); $month = $date["mon"]; $day = $date["mday"]; $year = $date["year"]; $expiryDate = $month . '/' . $day . '/' . $year; echo $expiryDate . ' ' . SQLact("result", $result,0,"ctime"); if ($expiry==0) { echo ' (less than a day left)'; } else if ($expiry >= 1) { echo ' (' . ( $expiry - $timeStamp ) / $secondsPerDay . ' day'; if ($expiry==1) {} else { echo 's'; } echo ' left)'; } else { echo ' (expired)'; } ?> </td> </tr> <tr> <td bgcolor=<? echo $tablecolor1; ?> valign=top><b>Project Creator:</td> <td bgcolor=<? echo $tablecolor1; ?> valign=top><? echo SQLact("result", $result,0,"creator"); ?><? $check = SQLact("query", "SELECT * FROM freelancers_webmasters WHERE username='" . SQLact("result", $result,0,"creator") . "' AND special='user'"); if (SQLact("num_rows", $check)==0) {} else { echo ' <a href="' . $siteurl . '/aboutspecial.php"><img src="' . $siteurl . '/images/special.gif" alt="Special User" border=0></a>'; } ?><br><small>Rating: <?php $result8 = SQLact("query", "SELECT AVG(rating) as average2 FROM freelancers_ratings WHERE username='" . SQLact("result", $result,0,"creator") . "' AND type='buyer' AND status='rated'"); if (SQLact("num_rows", SQLact("query", "SELECT * FROM freelancers_ratings WHERE username='" . SQLact("result", $result,0,"creator") . "' AND type='buyer' AND status='rated'"))==0) { echo '<small>(No Feedback Yet)'; } else { echo '<a href="' . $siteurl . '/feedback.php?b=' . SQLact("result", $result,0,"creator") . '">'; $avgratin8 = round(SQLact("result", $result8,0,"average2"), 2); $avgrating8 = explode(".", $avgratin8); for ($t28=0;$t28<$avgrating8[0];$t28++) { echo '<img src="' . $siteurl . '/images/star.gif" border=0 alt="' . $avgratin8 . '/10">'; } $numeric28 = 10-$avgrating8[0]; if ($numeric28==0) {} else { for ($b28=0;$b28<$numeric28;$b28++) { echo '<img src="' . $siteurl . '/images/star.gif" border=0 alt="' . $avgratin8 . '/10">'; } } if (SQLact("num_rows", SQLact("query", "SELECT * FROM freelancers_ratings WHERE username='" . SQLact("result", $result,0,"creator") . "' AND type='buyer' AND status='rated'"))==1) { echo ' (<b>1</b> review)'; } else { echo ' (<b>' . SQLact("num_rows", SQLact("query", "SELECT * FROM freelancers_ratings WHERE username='" . SQLact("result", $result,0,"creator") . "' AND type='buyer' AND status='rated'")) . '</b> reviews)'; } echo '</a>'; } ?> </td> </tr> <tr> <td valign=top><b>Description:</td> <td valign=top> <?php $desc = SQLact("result", $result,0,"description"); $desc = str_replace(" ", " ", $desc); $desc = str_replace(" ", "<br> ", $desc); echo $desc; ?> </td> </tr> <tr> <td bgcolor=<? echo $tablecolor1; ?> valign=top><b><? echo $catname; ?>:</td> <td bgcolor=<? echo $tablecolor1; ?> valign=top> <?php $archway = SQLact("result", $result,0,"categories"); $len=strlen($archway); $boink=substr("$archway", 0, ($len-2)); echo $boink; ?> </td> </tr> <?php $p1 = $tablecolor2; $p2 = $tablecolor1; $p3 = $tablecolor2; if ($attachmode == "enabled") { unset ($p1, $p2, $p3); $p1 = $tablecolor1; $p2 = $tablecolor2; $p3 = $tablecolor1; ?> <tr> <td bgcolor=<? echo $tablecolor2; ?> valign=top><b>Attachment:</td> <td bgcolor=<? echo $tablecolor2; ?> valign=top><? if ($mode == "demo") { echo 'Not available in demo!'; } else { if (SQLact("result", $result,0,"attachment") !== "") { echo '<a href="' . $attachurl . '/' . SQLact("result", $result,0,"attachment") . '" target="_blank">' . SQLact("result", $result,0,"attachment") . '</a>'; } else { echo 'No Attachment Uploaded.'; } } ?></td> </tr> <?php } if ($pcat1 == "") {} else { ?> <tr> <td bgcolor=<? echo $p1; ?> valign=top><b><? echo $pcat1; ?>:</td> <td bgcolor=<? echo $p1; ?> valign=top> <?php $boink1 = SQLact("result", $result,0,"pcat1val"); echo $boink1; ?> </td> </tr> <?php } if ($pcat2 == "") {} else { ?> <tr> <td bgcolor=<? echo $p2; ?> valign=top><b><? echo $pcat2; ?>:</td> <td bgcolor=<? echo $p2; ?> valign=top> <?php $boink2 = SQLact("result", $result,0,"pcat2val"); echo $boink2; ?> </td> </tr> <?php } if ($pcat3 == "") {} else { ?> <tr> <td bgcolor=<? echo $p3; ?> valign=top><b><? echo $pcat3; ?>:</td> <td bgcolor=<? echo $p3; ?> valign=top> <?php $boink3 = SQLact("result", $result,0,"pcat3val"); echo $boink3; ?> </td> </tr> <?php } ?> </table> <br /> <table width="100%" border="0"> <tr> <td><table width="100%" border="0"> <tr> <td class="warning"><div align="center">Notice from Thai-Freelancers.com's<br /> If you find any freelancers or employers whom post their contact information into the project or bid please contact us. This is a violation of our website agreement. If you bid on a project or contact a person with there details posted we will not be responsible nor will we help in anyway for any arbitration or problems. You also are risking losing and funds in escrow.</div></td> </tr> </table></td> </tr> </table> <br /> <table width="100%" border="<? echo $tableborder; ?>" cellspacing="<? echo $tablecellsp; ?>" cellpadding="<? echo $tablecellpa; ?>"> <tr> <td bgcolor=<? echo $tablecolorh; ?>><small><b><font color=<? echo $tablecolort; ?>><? echo $freelancer; ?></td> <td bgcolor=<? echo $tablecolorh; ?>><small><b><font color=<? echo $tablecolort; ?>>Bid</td> <td bgcolor=<? echo $tablecolorh; ?>><small><b><font color=<? echo $tablecolort; ?>>Delivery Within</td> <td bgcolor=<? echo $tablecolorh; ?>><small><b><font color=<? echo $tablecolort; ?>>Time of Bid</td> <td bgcolor=<? echo $tablecolorh; ?>><small><b><font color=<? echo $tablecolort; ?>><center>Rating</td> </tr> <?php $bees = SQLact("query", "SELECT * FROM freelancers_bids WHERE id='" . $id . "' ORDER BY amount ASC, date2 DESC"); if (SQLact("num_rows", $bees)==0) { echo '<tr> <td bgcolor="' . $tablecolor1 . '" align="center" colspan=5>(No bids have been placed yet.)</td> </tr>'; } else { while ($row=SQLact("fetch_array", $bees)) { ?> <tr> <td bgcolor="<? echo $tablecolor1; ?>"><a href="<? echo $siteurl; ?>/freelancers.php?viewprofile=<? echo $row[username]; ?>"><? echo $row[username]; ?></a> <? $dddres = SQLact("query", "SELECT * FROM freelancers_programmers WHERE username='$row[username]' AND special='user'"); if (SQLact("num_rows", $dddres)==0) {} else { echo ' <a href="' . $siteurl . '/aboutspecial.php"><img src="' . $siteurl . '/images/special.gif" alt="Special User" border=0></a>'; } ?> </td> <td bgcolor="<? echo $tablecolor1; ?>"><? echo $currencytype . '' . $currency; ?><? echo $row[amount]; ?></td> <td bgcolor="<? echo $tablecolor1; ?>"><? echo $row[delivery]; ?> day(s)</td> <td bgcolor="<? echo $tablecolor1; ?>"><? echo $row[date]; ?></td> <td bgcolor="<? echo $tablecolor1; ?>"><center> <small><? $chick = SQLact("query", "SELECT AVG(rating) as average FROM freelancers_ratings WHERE username='" . $row[username] . "' AND type='freelancer' AND status='rated'"); if (SQLact("num_rows", SQLact("query", "SELECT * FROM freelancers_ratings WHERE username='" . $row[username] . "' AND type='freelancer' AND status='rated'"))==0) { echo '<small>(No Feedback Yet)'; } else { echo '<a href="' . $siteurl . '/feedback.php?f=' . $row[username] . '">'; $avgratin = round(SQLact("result", $chick,0,"average"), 2); $avgrating = explode(".", $avgratin); for ($t2=0;$t2<$avgrating[0];$t2++) { echo '<img src="' . $siteurl . '/images/star.gif" border=0 alt="' . $avgratin . '/10">'; } $numeric2 = 10-$avgrating[0]; if ($numeric2==0) {} else { for ($b2=0;$b2<$numeric2;$b2++) { echo '<img src="' . $siteurl . '/images/star.gif" border=0 alt="' . $avgratin . '/10">'; } } if (SQLact("num_rows", SQLact("query", "SELECT * FROM freelancers_ratings WHERE username='" . $row[username] . "' AND type='freelancer' AND status='rated'"))==1) { echo ' (<b>1</b> review)'; } else { echo ' (<b>' . SQLact("num_rows", SQLact("query", "SELECT * FROM freelancers_ratings WHERE username='" . $row[username] . "' AND type='freelancer' AND status='rated'")) . '</b> reviews)'; } echo '</a>'; } ?></small> </td> </tr> <tr> <td bgcolor="<? echo $tablecolor1; ?>" colspan=5><small><? echo $row[details]; ?></td> </tr> <?php } } ?> </table> <p> <?php if (SQLact("result", $result,0,"status") == "closed" || SQLact("result", $result,0,"status") == "cancelled" || SQLact("result", $result,0,"status") == "frozen") {} else { ?> <a href="<? echo $siteurl; ?>/project.php?bid=<? echo $id; ?>"><img src="<? echo $siteurl; ?>/images/placebid.gif" border=0 alt="Place Bid"></a> <p> <a href="<? echo $siteurl; ?>/forum.php?viewproj=<? echo $id; ?>"><img src="<? echo $siteurl; ?>/images/viewboard.gif" border=0 alt="View Message Board for this Project"></a> <br> Messages Posted: <b><? echo SQLact("num_rows", SQLact("query", "SELECT * FROM freelancers_forum WHERE pid='" . $id . "'")); ?></b> <p> <?php } } } else if ($invite && $invite !== "") { $realun = SQLact("query", "SELECT * FROM freelancers_programmers WHERE username='$invite'"); if (SQLact("num_rows", $realun)==0) { include ("header.php"); echo 'No ' . $freelancer . ' account was found with the username <b>' . $invite . '</b><br> <a href="javascript:history.go(-1);">Go Back...</a>'; } else { if (!$submit) { $username = $HTTP_COOKIE_VARS["busername"]; $password = $HTTP_COOKIE_VARS["bpassword"]; include ("header.php"); ?> <b>Please login first</b> <p> <form method="POST" action="project.php"> <input type="hidden" name="invite" value="<? echo $invite; ?>"> <strong>Username:</strong><br> <small>(<a href="webmasters.php?forgot=find">Click here</a> if you forgot it.)</small> <br> <input type="text" name="username" value="<? echo $username; ?>" size="15"> <br> <strong>Password:</strong><br> <small>(<a href="webmasters.php?forgot=find">Click here</a> if you forgot it.)</small> <br> <input type="password" name="password" value="<? echo $password; ?>" size="15"> <br> <input type="submit" value="Login" name="submit"> </form> <?php } else { $bozzyres = SQLact("query", "SELECT * FROM freelancers_webmasters WHERE username='$username'"); $bozzyrows = SQLact("num_rows", $bozzyres); if ($bozzyrows==0) { include ("header.php"); echo 'No ' . $buyer . ' account was found with the username <b>' . $username . '</b>. <br> <A HREF="javascript:history.go(-1);">Go Back</A>'; } else { $byzzyres = SQLact("query", "SELECT * FROM freelancers_webmasters WHERE username='$username' AND password='$password'"); $byzzyrows = SQLact("num_rows", $byzzyres); if ($byzzyrows==0) { include ("header.php"); echo 'The password you provided is incorrect. <br> <A HREF="javascript:history.go(-1);">Go Back</A>'; } else { setcookie ("busername", $username,time()+999999); setcookie ("bpassword", $password,time()+999999); include ("header.php"); $result = SQLact("query", "SELECT * FROM freelancers_projects WHERE creator='$username' AND status='open'"); if (SQLact("num_rows", $result)==0) { echo 'You do not have any open projects right now, sorry.<br> <a href="' . $siteurl . '/webmasters.php?manage=2">Manage Account...</a>'; } else { if (!$confirm) { echo '<form method="POST" action="project.php"> <input type="hidden" name="invite" value="' . $invite . '"> <input type="hidden" name="username" value="' . $username . '"> <input type="hidden" name="password" value="' . $password . '"> <input type="hidden" name="submit" value="Login"> <strong>Which project would you like to invite <a href="' . $siteurl . '/freelancers.php?viewprofile=' . $invite . '">' . $invite . '</a> to bid on?</strong> <select name="project" size="1"> '; while ($row=SQLact("fetch_array", $result)) { echo '<option value="' . $row[id] . '">' . $row[project] . '</option> '; } echo '</select> <input type="submit" value="Invite" name="confirm"> </form>'; } else { $emaddr = SQLact("result", $realun,0,"email"); $mymess = $emailheader . ' ---------- ' . $username . ' has just invited you to place a bid on their project. The name of the project is "' . SQLact("result", $result,0,"project") . '" and you can view it at the following URL: ' . $siteurl . '/project.php?id=' . SQLact("result", $result,0,"id") . ' ---------- ' . $emailfooter; mail($emaddr,$companyname . " Project Invitation",$mymess,"From: $emailaddress"); echo 'Done. Your invitation has been successfully sent to <b>' . $invite . '</b>.'; } } } } } } } else if ($bid && $bid !== "") { $hugeres2 = SQLact("query", "SELECT * FROM freelancers_suspends WHERE ip='" . $REMOTE_ADDR . "'"); $hugerows2 = SQLact("num_rows", $hugeres2); if ($hugerows2==0) { $result = SQLact("query", "SELECT * FROM freelancers_projects WHERE id='$bid' AND status='open'"); if (SQLact("num_rows", $result)==0) { include ("header.php"); echo 'ERROR: No project was found with that ID number or the project found is not currently open for bidding.<br> <a href="javascript:history.go(-1);">Go Back...</a>'; } else { if (!$submit) { $username = $HTTP_COOKIE_VARS["fusername"]; $password = $HTTP_COOKIE_VARS["fpassword"]; include ("header.php"); echo '<form method="POST" action="project.php"> <input type="hidden" name="bid" value="' . $bid . '"> <big><b>Bid on Project: ' . SQLact("result", $result,0,"project") . '</b></big> <p> <p> <strong>Username:</strong><br> <small>(<a href="' . $siteurl . '/freelancers.php?new=user">Click here to signup</a>)</small> <br> <input type="text" name="username" value="' . $username . '" size="15"> <p> <strong>Password:</strong><br> <input type="password" name="password" value="' . $password . '" size="15"> <p> <strong>Your bid for the total project:</strong><br>'; if (SQLact("result", $result,0,"budgetmin") == "" && SQLact("result", $result,0,"budgetmax") !== "") { echo '<small>Project budget maximum is ' . $currencytype . '' . $currency . '' . SQLact("result", $result,0,"budgetmax") . '</small><br>'; } else if (SQLact("result", $result,0,"budgetmin") !== "" && SQLact("result", $result,0,"budgetmax") == "") { echo '<small>Project budget minimum is ' . $currencytype . '' . $currency . '' . SQLact("result", $result,0,"budgetmin") . '</small><br>'; } else if (SQLact("result", $result,0,"budgetmin") !== "" && SQLact("result", $result,0,"budgetmax") !== "") { echo '<small>Project budget is ' . $currencytype . '' . $currency . '' . SQLact("result", $result,0,"budgetmin") . ' - ' . $currencytype . '' . $currency . '' . SQLact("result", $result,0,"budgetmax") . '</small><br>'; } echo $currencytype . '' . $currency . '<input type="text" name="bidamount" maxlength="6" size="6"> <p> <strong>In how many days can you deliver a completed project?</strong><br> <small>'; $secondsPerDay = ((24 * 60) * 60); $timeStamp = time(); $daysUntilExpiry = SQLact("result", $result,0,"expires"); $expiry = $timeStamp + ($daysUntilExpiry * $secondsPerDay); $date = getdate($expiry); $month = $date["mon"]; $day = $date["mday"]; $year = $date["year"]; $expiryDate = $month . '/' . $day . '/' . $year; echo '(The user wants the project completed by ' . $expiryDate. ', which is '; if ($expiry==0) { echo 'in less than one day.)'; } else if ($expiry>=1) { echo 'in ' . ( $expiry - $timeStamp ) / $secondsPerDay . ' day'; if ($expiry==1) {} else { echo 's'; } echo '.)'; } else { echo 'expired.)'; } echo '</small> <br> <input type="text" name="days" maxlength="3" value="' . ( $expiry - $timeStamp ) / $secondsPerDay . '" size="5"> Day(s) <p> <strong>Provide the details of your bid (optional):</strong><br> <textarea rows="8" name="details" cols="52"></textarea> <p> <input type="checkbox" name="outbid" value="y"> Notify me by e-mail if someone bids lower than me on this project. <p> <input type="submit" value="Place Bid" name="submit"> </form>'; } else { if ($username == "" || $password == "" || $bidamount == "" || $days == "") { include ("header.php"); echo 'ERROR: You have left 1 or more required fields blank.<br> <a href="javascript:history.go(-1);">Go Back...</a>'; } else { $bozzyres = SQLact("query", "SELECT * FROM freelancers_programmers WHERE username='$username'"); $bozzyrows = SQLact("num_rows", $bozzyres); if ($bozzyrows==0) { include ("header.php"); echo 'No ' . $freelancer . ' account was found with the username <b>' . $username . '</b>. <br> <A HREF="javascript:history.go(-1);">Go Back</A>'; } else { $byzzyres = SQLact("query", "SELECT * FROM freelancers_programmers WHERE username='$username' AND password='$password'"); $byzzyrows = SQLact("num_rows", $byzzyres); if ($byzzyrows==0) { include ("header.php"); echo 'The password you provided is incorrect. <br> <A HREF="javascript:history.go(-1);">Go Back</A>'; } else { setcookie ("fusername", $username,time()+999999); setcookie ("fpassword", $password,time()+999999); include ("header.php"); $today = getdate(); $month = $today['mon']; $day = $today['mday']; $year = $today['year']; $hours = $today['hours']; $minutes = $today['minutes']; $bidremind = SQLact("query", "SELECT * FROM freelancers_bids WHERE id='$bid' AND amount>$bidamount AND outbid='y' AND username!='$username'"); while ($row=SQLact("fetch_array", $bidremind)) { $emails = SQLact("query", "SELECT * FROM freelancers_programmers WHERE username='" . $row[username] . "'"); $mymess = $emailheader . ' ---------- ' . $username . ' has just outbid you on a project. You can view the project and place a new bid at ' . $siteurl . '/project.php?id=' . $bid . ' ---------- ' . $emailfooter; mail(SQLact("result", $emails,0,"email"),$companyname . " Project Outbid Notice",$mymess,"From: $emailaddress"); } $bidnotify = SQLact("query", "SELECT * FROM freelancers_webmasters WHERE username='" . SQLact("result", $result,0,"creator") . "'"); if (SQLact("result", $bidnotify,0,"bidnotify") !== "") { $mymess2 = $emailheader . ' ---------- ' . $username . ' has just bid ' . $currencytype . '' . $currency . '' . $bidamount . ' on your project. You can view the details at ' . $siteurl . '/project.php?id=' . $bid . ' ---------- ' . $emailfooter; mail(SQLact("result", $bidnotify,0,"email"),$companyname . " Project Bid Notice",$mymess2,"From: $emailaddress"); } $prevbid = SQLact("query", "SELECT * FROM freelancers_bids WHERE id='$bid' AND username='$username'"); if (SQLact("num_rows", $prevbid)==0) { SQLact("query", "INSERT INTO freelancers_bids (username, status, id, project, special, amount, delivery, date, details, date2, chosen, outbid) VALUES ('$username', 'open', '$bid', '" . SQLact("result", $result,0,"project") . "', '" . SQLact("result", $result,0,"special") . "', '$bidamount', '$days', '$month/$day/$year @ $hours:$minutes', '$details', '" . time() . "', '', '$outbid')"); echo '<br><center><b>Your bid has been recorded successfully. If you decide to place a new bid on this project, your old one will be erased.<br> You will be notified by e-mail when this project ends.</b><br> <a href="' . $siteurl . '/project.php?id=' . $bid . '">Go back...</a> <META HTTP-EQUIV=REFRESH CONTENT="30; URL=' . $siteurl . '/project.php?id=' . $bid . '">'; } else { SQLact("query", "UPDATE freelancers_bids SET username='$username', status='open', id='$bid', project='" . SQLact("result", $result,0,"project") . "', special='" . SQLact("result", $result,0,"special") . "', amount='$bidamount', delivery='$days', date='$month/$day/$year @ $hours:$minutes', details='$details', date2='" . time() . "', chosen='', outbid='$outbid' WHERE id='$bid' AND username='$username'"); echo '<br><center><b>Your bid has been recorded successfully. If you decide to place a new bid on this project, your old one will be erased.<br> (NOTE: Your old bid was replaced with this one.)<br> You will be notified by e-mail when this project ends.</b><br> <a href="' . $siteurl . '/project.php?id=' . $bid . '">Go back...</a> <META HTTP-EQUIV=REFRESH CONTENT="30; URL=' . $siteurl . '/project.php?id=' . $bid . '">'; } } } } } } } else { echo 'You have been suspended from using ' . $companyname . '!<br> You do not have access to bid on projects used in this section of the website!<br> The reason for your suspension is:<br> <b><i>'; $humanres2 = SQLact("query", "SELECT * FROM freelancers_suspends WHERE ip='" . $REMOTE_ADDR . "'"); $rrreason2 = SQLact("result", $humanres2,0,"reason"); if ($rrreason2 == "") { echo 'No reason was given for your suspension.'; } else { echo $rrreason2; } echo '</i></b><br><br> If you think there has been a mistake, contact ' . $emailaddress; } } else { echo 'No project was found with that ID number.'; } include ("footer.php"); ?>
|
|
|
|
06-11-2008, 12:28 AM
|
Re: How to Encode / Decode through a form
|
Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
|
Try this on your table:
Code:
ALTER TABLE `table_name` CHANGE `field` `field` TYPE CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
Substitute table_name with your table's name, field with the field's name, TYPE with the type (for example, TEXT or VARCHAR (32)).
__________________
PHP Code:
<?php echo "Hello World"; ?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
|
|
|
|
06-12-2008, 11:44 AM
|
Re: How to Encode / Decode through a form
|
Posts: 34
Name: Jin
Location: Bangkok
|
Before I try this I am wondering will this encode everything? Meaning if someone posts English will it try to convert it to an encoding? Or only if other languages are posted?
|
|
|
|
06-12-2008, 03:19 PM
|
Re: How to Encode / Decode through a form
|
Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
|
UTF is 'Universal Text Format' and contains pretty much every character. It can store all the latin sets and several others too. It also has different characters. I prefer ASCII when writing a text file, but I only ever use UTF-8 while writing for the web.
__________________
PHP Code:
<?php echo "Hello World"; ?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
|
|
|
|
06-18-2008, 01:36 AM
|
Re: How to Encode / Decode through a form
|
Posts: 34
Name: Jin
Location: Bangkok
|
There was an error when I did this so I am sure I am not doing it properly sorry but I don’t know much about MySQL. I see in your example you have “field” two times is that correct?
Right now in the database it has
Table = sbprj_messages
Field = sb_msgtext
Type = longtext
Can you put them in the proper spot so I can copy right from here.
|
|
|
|
06-28-2008, 03:11 PM
|
Re: How to Encode / Decode through a form
|
Posts: 34
Name: Jin
Location: Bangkok
|
Anybody can help me figure this out? Sorry I know very little about MySQL and really need guidence with these kinds of things.
|
|
|
|
|
« Reply to How to Encode / Decode through a form
|
|
|
| Thread Tools |
Search 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
HTML code is Off
|
|
|
|