Jump to content

This topic is 6980 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have gotten the statement below to work:

<?php

if ($searchResult['foundCount']==1)

{

}else{

echo "There was no match for the email address your entered. Press the back button and try again or

call Us at 000-000-0000" ;

}

?>

It follows the beginning php code (<?php) at the start of the page before .

I would like to be able to format the response in html (There was no match...), but don't know how to format or place the above statement within the

.

Thanks in advance for your help - Sam

Posted

Sam,

Try this:

<?php

$message = "";

if ($searchResult['foundCount']==1)

{

}else{

$message = "There was no match for the email address your entered. Press the back button and try again or

call Us at 000-000-0000" ;

}

?>

.....

<?=$message?>

......

Posted

Thanks Garry,

<?=$message?> Worked!

How would I format the $message text with carriage returns or any other html formating? The text "There was no match..." all runs along one line.

How would I add a graphic image?

Thanks again, you are always a great help - Sam

Posted

Try this:

$message = "There was no match for the email address your entered.

Press the back button and try again or

call Us at 000-000-0000" ;

then in the html...

<? echo $message; ?>

Another option would be to set a flag:

<?php

$flag = 0;

if ($searchResult['foundCount']==1)

{

}else{

$flag = 1 ;

}

?>

then in your html:

<? if(flag==1) { ?>

no records found blah blah blah

call us... blah blah

etc

<? } ?>

Posted

You could do it this way:

<?php

$message = False;

if ($searchResult['foundCount']==1)

{

}else{

$message = True;

}

?>

.....

<?php if($message) { ?>

There was no match for the email address your entered.

Press the back button and try again or

call Us at 000-000-0000

<?php }; ?>

......

Posted

Thanks to Garry and Mindal,

Garry's solution is the one that came close to working, but when there is a $message = True, the page just displays the number "1".

Mindal's two solution either gave me blank page or the the text showed, but was not formated.

What could I be doing wrong? I copied and pasted the code into my php document with the first string of code placed above the head and the second string of code placed in the body.

Thanks again - Sam

Posted

both our codes would need some fine tuning to make it specifically work for your solution.

The best method is to set the flag (either use true / false or a number).

copy the code as you have it and post it and if either Gary or I get time, I am sure we can make the few edits to help you out.

Posted (edited)

Mindal,

I have included the code below. When the FoundCount==1 the page displays correctly. When the FoundCount==0 I get a blank page.

<?php

include_once('FX/FX.php');

include_once('FX/FMErrors.php');

include_once('FX/server_data.php');

$email=$_POST['email'];

$groupSize='1';

$search=new FX($serverIP,$webCompanionPort,'FMPro7');

$search->SetDBData('XXX.fp7','php',$groupSize);

$search->SetDBPassword('XXX','XXX');

$search->AddDBParam('email',$email);

$searchResult=$search->FMFind();

?>

<?php

$flag = 0;

if ($searchResult['foundCount']==1)

{

}else{

$flag = 1 ;

}

?>

<?php

foreach($searchResult['data'] as $key=>$searchData){

?>

Email User Id and Password

<? if(flag==1) { ?>logo.gif

There was no match for the email address your entered.

Press the back button and try again or call Us at 000-000-000. <? } ?>

Thanks agin - Sam

Edited by Guest
Posted

<?php if($flag==1) { ?>

logo.gif

There was no match for the email address your entered.

Press the back button and try again or call Us at 000-000-000.

<?php }

else {

foreach($searchResult['data'] as $key=>$searchData) {

?>

Do Something!

<?php }; };?>

Posted

Hi Garry,

I copied and pasted your code into my document, but I still come up with a blank page when there is no match. When there is a match then I get the information that is suppose to be there.

Maybe the problem is on the page that the query is being submitted from. I discovered in FileMaker that and email address cannot be searched without double equal signs ==. So the text entry field has "==" already in the box. This is probably not a very elegant way of making sure there is a match. I know there is a way of doing this on the the page the form is being submitted to, but have not gotten it to work. The search field is "email". Could this be causing the problem in getting the result page to display properly depending on if there was a match or not?

Thanks - Sam

Posted

FoundCount = <? echo $searchResult['foundCount']?>

<? if($flag==1) { ?>

logo.gif

There was no match for the email address your entered.

Press the back button and try again or call Us at 000-000-000.

<? } ?>

This text is here to prove we don't get a blank page.

Posted

<?php if($flag==1) { ?>

logo.gif

There was no match for the email address your entered.

Press the back button and try again or call Us at 000-000-000.

<?php }

else {

foreach($searchResult['data'] as $key=>$searchData) {

?>

<?php }; };?>

logo.gif

<?php

}

?>

<?php echo $searchData['web_title'][0]; ?> here is your email Information.

<?php echo $searchData['email'][0]; ?>

Posted

Interesting about the '==' is that I search for email addresses in filemaker and do not need to use it.

My code that I posted should work. To test it out, change only the database information in the PHP at the top and try it and see.

I am also want to see what code you are using on the form that sends information to this page.

On the page you just posted there are a few errors.

Since you only want to find 1 record, you do not need to loop your foreach statement (ie drop the '{ }')

There are also some useful error checking codes you could insert to try and track where your data is going.

echo $searchResult['errorCode'];

And my favourite:

print "

-";

print_r($searchData);

print "-

";

I want to see this work and you are probably not that far away from getting this solved.

Posted

oops,

I forgot one valuable piece of information that I recall when I needed to do this. The '@' symbol is problems and the best way around it is to enclose the $email inside double quotes.

insert this code below $groupSize=1;

$email = '"'.$email.'"';

I have tested this on my databases and it works.

Posted

Mlindal,

Thanks for your efforts, I do really appreciate it, but it did not work. I get blank pages for when the query matches and when it does not match. I am going all the way back to a less elegant solution, but one that works.

Thanks again to you and Garry - Sam

Posted

If you get blank pages then there is some error that has crept in.

like I said the pages I sent you (with the addition of the $email = '"'.$email.'"';) work excellent on my system. I have a similar need to search for email addresses for clients that forget their userid.

I guess go with what works - but there may be something wrong with your configuration.

Good luck.

This topic is 6980 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.