DBookatay Posted November 1, 2007 Share Posted November 1, 2007 I have a script, (which I did not create) that makes form fields required… [code]<? function formatText($inputName,$text) { if ($_SERVER['REQUEST_METHOD']=="POST") { if(empty($_POST[$inputName])) { echo '<span class="redBold">'.$text.'</span>'; $_SESSION['ispassed']=false; } else {echo $text;} } else echo $text; } ?> and then: <td><? formatText("nmF","First:"); ?></td> This way works fine, but what I am now trying to do is to put it into a php page that is already echoing an output. Basically: <td>’.formatText("nmF","First:").’</td> Problem is, all the text gets echoed at the top of the page, not where I want it, in the <td>. I’ve tried to change all the “echos” and tried <td>’.$formatText("nmF","First:").’</td> but it throws errors… Any ideas?[/code] Quote Link to comment https://forums.phpfreaks.com/topic/75587-solved-minor-tweek-needed-on-a-current-script/ Share on other sites More sharing options...
pocobueno1388 Posted November 1, 2007 Share Posted November 1, 2007 Show us more code that goes along with <td>’.formatText("nmF","First:").’</td> Also, what are the errors? Quote Link to comment https://forums.phpfreaks.com/topic/75587-solved-minor-tweek-needed-on-a-current-script/#findComment-382446 Share on other sites More sharing options...
DBookatay Posted November 1, 2007 Author Share Posted November 1, 2007 Show us more code that goes along with <td>.formatText("nmF","First:").</td> Also, what are the errors? The only other code is the input: <input type="text" name="nmF" value=""> Quote Link to comment https://forums.phpfreaks.com/topic/75587-solved-minor-tweek-needed-on-a-current-script/#findComment-382447 Share on other sites More sharing options...
pocobueno1388 Posted November 1, 2007 Share Posted November 1, 2007 Well, post the entire code then. <td>’.formatText("nmF","First:").’</td> That is obviously not the entire line...there has to be an echo or print in there. Quote Link to comment https://forums.phpfreaks.com/topic/75587-solved-minor-tweek-needed-on-a-current-script/#findComment-382450 Share on other sites More sharing options...
DBookatay Posted November 1, 2007 Author Share Posted November 1, 2007 Well, post the entire code then. <td>.formatText("nmF","First:").</td> That is obviously not the entire line...there has to be an echo or print in there. This is the entire code... [code]<? function formatText($inputName,$text) { if ($_SERVER['REQUEST_METHOD']=="POST") { if(empty($_POST[$inputName])) { echo '<span class="redBold">'.$text.'</span>'; $_SESSION['ispassed']=false; } else {echo $text;} } else echo $text; } ?> If you want to see it in action, go here: http://www.carcityofdanbury.com/apply.php?applicant=single I am now trying to change that page, so I need to change the code as well....[/code] Quote Link to comment https://forums.phpfreaks.com/topic/75587-solved-minor-tweek-needed-on-a-current-script/#findComment-382454 Share on other sites More sharing options...
pocobueno1388 Posted November 1, 2007 Share Posted November 1, 2007 No...I don't want the code to the function. I want the code to where you are trying to USE the function. Quote Link to comment https://forums.phpfreaks.com/topic/75587-solved-minor-tweek-needed-on-a-current-script/#findComment-382459 Share on other sites More sharing options...
DBookatay Posted November 1, 2007 Author Share Posted November 1, 2007 No...I don't want the code to the function. I want the code to where you are trying to USE the function. <? //Required Fields function formatText($inputName,$text) { if ($_SERVER['REQUEST_METHOD']=="POST") { if(empty($_POST[$inputName])) { echo '<span class="redBold">'.$text.'</span>'; $_SESSION['ispassed']=false; } else {echo $text;} } else echo $text; } if(isset($_GET['regType'])); switch($_GET['regType']) { case 'Rep': $regType = ' <table> <tr> <td valign="top"> <!-- START LEFT --> <div id="sctnTle">Personal Information</div> <div id="sctnHldr"> <table> <tr> <td class="frm">'.formatText("nmF","First") .'</td> <td width="10" rowspan="2"> </td> <td class="frm">M.</td> <td width="10" rowspan="2"> </td> <td class="frm">'.formatText("nmL","Last") .'</td> </tr> <tr> <td><input id="input" type="text" name="nmF" size="20" autocomplete="off" value="'.$POST_nmF.'" /></td> <td><input id="char1" type="text" name="nmM" size="1" autocomplete="off" maxlength="1" value="'.$POST_nmM.'" onKeyup="autotab(this, document.form.nmL)" /></td> <td><input id="input" type="text" name="nmL" size="24" autocomplete="off" value="'.$POST_nmL.'" /></td> </tr> <tr><td class="frmPad" colspan="5">'.formatText("email1","Email Address") .'</td></tr> <tr><td colspan="5"><input id="input" type="text" name="email1" size="40" autocomplete="off" value="'.$POST_email1.'" /></td></tr> <tr><td class="frmPad" colspan="5">'.formatText("email2","Confirm Email Address") .'</td></tr> <tr><td colspan="5"><input id="input" type="text" name="email2" size="40" autocomplete="off" value="'.$POST_email2.'" /></td></tr> </table> <table> <tr><td class="frmPad">Time Zone</td></tr> <tr><td>'.$timezones.'</td></tr> </table> </div> <div id="sctnTle">Login Information</div> <div id="sctnHldr"> <table> <tr><td class="frm">'.formatText("uname","Desired Username") .'</td></tr> <tr><td><input id="input" type="text" name="uname" size="35" autocomplete="off" value="'.$POST_uname.'" /></td></tr> <tr><td class="frmPad">'.formatText("pass1","Password") .'</td></tr> <tr><td><input id="input" type="password" name="pass1" size="35" autocomplete="off" value="'.$POST_pass1.'" /></td></tr> <tr><td class="frmPad">'.formatText("pass2","Confirm Password") .'</td></tr> <tr><td><input id="input" type="password" name="pass2" size="35" autocomplete="off" value="'.$POST_pass2.'" /></td></tr> </table> </div>'; break; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/75587-solved-minor-tweek-needed-on-a-current-script/#findComment-382463 Share on other sites More sharing options...
pocobueno1388 Posted November 1, 2007 Share Posted November 1, 2007 Problem is, all the text gets echoed at the top of the page, not where I want it, in the <td>. I’ve tried to change all the “echos” and tried <td>’.$formatText("nmF","First:").’</td> but it throws errors… So it is printing out how you want it, it's just not showing up in the right spot? If thats the case, then it's an HTML problem, not PHP. Throwing errors? What kind of errors? I'm just confused now Quote Link to comment https://forums.phpfreaks.com/topic/75587-solved-minor-tweek-needed-on-a-current-script/#findComment-382470 Share on other sites More sharing options...
DBookatay Posted November 1, 2007 Author Share Posted November 1, 2007 Look at this page: http://bestsalesreps.com/index.php?main=004®Type=Rep here the error I am having is clearly shown. Instead of the input names "First" , "Last" etc echoing where they should (above the input box) they are showing up at the top of the page... That I what I am trying to solve... Quote Link to comment https://forums.phpfreaks.com/topic/75587-solved-minor-tweek-needed-on-a-current-script/#findComment-382492 Share on other sites More sharing options...
DBookatay Posted November 1, 2007 Author Share Posted November 1, 2007 Look at this page: http://bestsalesreps.com/index.php?main=004®Type=Rep here the error I am having is clearly shown. Instead of the input names "First" , "Last" etc echoing where they should (above the input box) they are showing up at the top of the page... That I what I am trying to solve... Anyone??? Quote Link to comment https://forums.phpfreaks.com/topic/75587-solved-minor-tweek-needed-on-a-current-script/#findComment-382507 Share on other sites More sharing options...
DBookatay Posted November 2, 2007 Author Share Posted November 2, 2007 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/75587-solved-minor-tweek-needed-on-a-current-script/#findComment-383169 Share on other sites More sharing options...
DBookatay Posted November 2, 2007 Author Share Posted November 2, 2007 Got it... function formatText($inputName,$text) { if ($_SERVER['REQUEST_METHOD']=="POST") { if (empty($_POST[$inputName])) { return '<span class="redBold">'.$text.'</span>'; $_SESSION['ispassed']=false; } else { return $text; } } else { return $text; } } Had to change all "echo"s to "return". Quote Link to comment https://forums.phpfreaks.com/topic/75587-solved-minor-tweek-needed-on-a-current-script/#findComment-383295 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.