Jump to content
Sign in to follow this  
thomas_xyz

isset, elseif, help

Recommended Posts

Hello everyone, I'm new to php so please bare with me on this. Before i explain my problem, let me give you guys a brief background on what i'm doing.i have a list of existing clients in my database that have a client# hence $code. Every clients will be sent an email that contain a link with their # aka $code. so when they arrive at my page, the address bar should also contain their $code.At the same time, there are also potential clients going to my webpage without client# ($code). Eventually both existing and potential clients will have to fill out a form. with their name and email. Problem #1:This is where I have difficulty in. Instead of making 2 separate website, which is very unnecessary. I want to set the form up according to those that enter the website with $code or without. Those with $code will be directed to request.php where they will fill in more information and those without will go to thankyou.php where the message "thank you for your request, a client id will be email to you shortly ." Unfortunately I can't get it to work, it only directs to thankyou.php with or without $code on the address bar. Please help me out. This is what I have on my index page.

<?php $code=$_REQUEST['code'];$email=$_REQUEST['email'];?><html><head><title></title></head><body><form action="<?php if (isset($code)) echo 'request.php'; else echo 'thankyou.php'; ?>" method="post"> <input type="text" class="inputbg"  name="FullName" id="FullName" onfocus="if (this.value == 'Your Name') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Your Name';}" value="Your Name" /> <input type="text" class="inputbg"  name="Email" id="Email" onfocus="if (this.value == 'Your Email') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Your Email';}" value="Your Email" />												  <input type="hidden" name="Code" value="<?=$Code;?>" /> 							  <input type="submit" class="submit"  name="submit" value="<?php if (isset($code)) echo 'More Info'; else echo 'Continue';?>" /> </form> </body></html>

Problem #2:I want to make the thankyou.php the result page where clients review their input for both sets of clients.Those with $code, I would want the page to show Name, email, phone, and appointment.For those without, I just want to show Name and email. This is what I have:

<?php $FullName=$_REQUEST['FullName'];$Code=$_REQUEST['Code'];$Email=$_REQUEST['Email'];$Phone=$_REQUEST['Phone'];$BestTime=$_REQUEST['BestTime'];$theDate = isset($_REQUEST["date5"]) ? $_REQUEST["date5"] : "";$theDate = date('F-j-Y', strtotime($theDate));?><html><head><title></title></head><body><h1 class="heading" style="font-size:40px;">Thank you <?=$FullName;?> for your submission!</h1> <p style="padding:20px 0px 0px">	 <h5>Your Email is: <?=$Email?>. </h5><?phpif (isset($code)) echo '[i]<h5>Your Personalized Code is: $Code. </h5>[/i][i]<h5> The phone number we had on file is $Phone</h5>[/i][i]<h5> You have scheduled a phone call on $theDate ,[/i][i]$BestTime -EST.</h5></p>[/i][i]<p style="color:#ffffff;">	  *Selected appointment will adjust accordingly to Eastern Standard Time (-EST).</p>'[/i] [i]else[/i] echo "An email with a client I.D. will be email to you shortly."?> </body></html>

I honestly thought the string

if (isset($code)) ""; else "";

sting is all i need but no matter what, it only shows the second echo and never the first. I'm a little confuse at this point so if anybody out there knows how to fix this, please help me out. thank you! P.S. if anyone is confused by what i type, please let me know. Thank you.

Edited by thomas_xyz

Share this post


Link to post
Share on other sites

Instead of isset() use empty(). $code is always set.

Share this post


Link to post
Share on other sites

do one thingdont assign $_REQUEST['variable'] to any ohter php variable directly. ( in ur case this step => $code=$_REQUEST['code'] )first check is whether they are set or notreplace this isset($_REQUEST['code'] $code=$_REUEST['code'];for each attribute or variable.

Share this post


Link to post
Share on other sites

no it should be $_REQUEST['code'] only... and this will only work if u have submitted (using post/get) this value from somewhere else.. but as u said u already have this value means u have stored that in session or somewhere else.. so first get the value from there..

Share this post


Link to post
Share on other sites

i did use $_REQUEST['code'] but still nothing. as for <input type="hidden" name="Code" value="<?=$Code;?>, i want to continuously use the code for the next following pages. as for $code=$_REQUEST['code']; there will be a variable when someone clicks on their email link.

Share this post


Link to post
Share on other sites

in index.php if(isset($_REQUEST['code'])) <input type=hidden name= Code value="<?php echo $_REQUEST['code'];?>"and then again in thankyou.php if(isset($_REQUEST['code'])){ }else{ echo "An email with a client I.D. will be email to you shortly."} something llike this..

Share this post


Link to post
Share on other sites

index.php

<?phpif (isset ($_REQUEST['Code']));$Code=$_REQUEST['Code'];?><html><head><title></title></head><body><form action="<?php if (isset($_REQUEST['Code'])) echo 'request.php'; else echo 'thankyou.php'; ?>" method="post"><input type="text" class="inputbg"  name="FullName" id="FullName" onfocus="if (this.value == 'Your Name') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Your Name';}" value="Your Na<input type="text" class="inputbg"  name="Email" id="Email" onfocus="if (this.value == 'Your Email') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Your Email';}" value="Your Email" />						  <input type="hidden" name="Code" value="<?php echo $_REQUEST['Code'];?>" /><input type="submit" class="submit"  name="submit" value="<?php if (isset($_REQUEST['Code'])) echo 'More Info'; else echo 'Continue';?>" />	 </form></body></html>

Correct?thankyou.php

<?php $FullName=$_REQUEST['FullName']; $Code=$_REQUEST['Code'];$Email=$_REQUEST['Email'];$Phone=$_REQUEST['Phone'];$BestTime=$_REQUEST['BestTime'];$theDate = isset($_REQUEST["date5"]) ? $_REQUEST["date5"] : "";$theDate = date('F-j-Y', strtotime($theDate));?><html><head><title></title></head><body> <?phpif (isset ($_REQUEST['Code'])) echo'<h5>Your Code is: <?=$Code;?>. </h5>		 <h5> The phone number we had on file is <?=$Phone;?></h5>		 <h5> You have scheduled a phone call on <?=$theDate;?> ,<?=$BestTime;?> -EST.</h5>		 </p><p style="color:#ffffff;"> <u>	 *Selected appointment will adjust accordingly to Eastern Standard Time (-EST).</u></p>';else'An email with a Code will be email to you shortly.'?>  </body></html>

Correct? btw thank you so much for the help. i'm still very new at this

Edited by thomas_xyz

Share this post


Link to post
Share on other sites

in thankyou.php <?php $FullName=$_REQUEST['FullName']; if(isset($_REQUEST['code'])) $Code=$_REQUEST['Code'];.............................//your code//........................?><html><head><title></title></head><body> <?phpif (isset($_REQUEST['Code'])) echo '....................................';else echo 'An email with a Code will be email to you shortly.';?> </body></html>

Share this post


Link to post
Share on other sites

just to avoid starting another topic,let just say i want to add an extra text input for those without $code how will i do so? i mean i would want it to only appear to those that enters the site without $code i've tried adding

  <?php if($code='') echo  ' <input type="text" class="inputbg" name="Tel" id="Tel" onfocus="if (this.value == \'Your Phone Number\') {this.value = '';}" onblur="if (this.value == '') {this.value = \'Your Phone Number\';}" value="Your Phone Number" />'?>       

but that doesn't seem to work

Edited by thomas_xyz

Share this post


Link to post
Share on other sites

well.. you see.. i've also attached another php with a mail() so everything they put in, it will get email to me once they hit submit. the phone number will be given to the sales people. so if i put that in the index, all potential clients have to do is fill out one form to complete the transaction. existing clients will fill out the first form then enter another form to make an appointment

Share this post


Link to post
Share on other sites

When you have an if statement you need to use == or === to compare values, using = assigns a value. You're assigning $code to be an empty string, not checking if it is empty.

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...